Basically, I want to convert the UTC date time to MT date time format. Any Leads?
Hi @laraiv.khan ,
- Use the
ParseExact
method of theDateTime
structure to parse thedateTime
variable using the original date format. For example, if the original date format is “MM/dd/yyyy hh:mm:ss tt”, you can use the following expression:dateTime = DateTime.ParseExact(dateTimeString, "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture)
wheredateTimeString
is the string representation of thedateTime
variable. - Set the time zone of the
dateTime
variable to Mountain Standard Time (MST) using theTimeZoneInfo.ConvertTime
method. For example, if you want to convert to Mountain Daylight Time (MDT), you can use the following expression:dateTime = TimeZoneInfo.ConvertTime(dateTime, TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time"), TimeZoneInfo.FindSystemTimeZoneById("Mountain Daylight Time"))
- Convert the
dateTime
variable back to a string representation using the desired format. For example, if you want to use the format “MM/dd/yyyy hh:mm:ss tt”, you can use the following expression:dateTimeString = dateTime.ToString("MM/dd/yyyy hh:mm:ss tt")
Thanks,
Hi @laraiv.khan, welcome back to the Community.
The following thread has the discussion related to the conversion of UTC to a specified timezone:
Hope this helps.
Best Regards.
Thanks @RajKumar_DC
1 Like
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.