Date Format string (source/destination) Conversion

Hi Team - I have a string in date & Time format with time zone.

Ex: 03/25/2024 11:04:34 PM EST

I want to convert the above to a destination string to save. Like 03252024_230434

Any suggestions on the conversion?

My problem is timezone in the source string and date format conversion.

1 Like

Hi @KrishnaKishore

Try this:
Input = "03/25/2024 11:04:34 PM EST"

Output = DateTime.ParseExact(Input.Replace("EST","").Trim(), "MM/dd/yyyy hh:mm:ss tt",System.Globalization.CultureInfo.InvariantCulture).ToString("MMddyyyy_HHmmss")

Regards

Hi,

If input string always has EST, the following will work

DateTime.ParseExact(yourString,"MM/dd/yyyy hh:mm:ss tt EST",System.Globalization.CultureInfo.InvariantCulture).ToString("MMddyyyy_HHmmss")

Or if it may be changed, we need to remove timezone info in advance.

Regards,

Thanks, That worked.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.