Can anyone help me out for the time zone task. I have machine time zone as “(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi”. I have task to check the system time zone and If it’s EST should print the EST time and date, If not I should convert it to EST time zone and print the EST time zone.
Note: “systemTimeZoneInfo” and “targetTimeZoneInfo” variables are of Data Type System.TimeZoneInfo and “estTime” variable is of Data Type System.DateTime.
1. Assign - systemTimeZone = System.TimeZoneInfo.Local
2. If - systemTimeZone.Id <> "Eastern Standard Time"
Then:
Assign - timeDifference = TimeSpan.FromHours(-5) // Calculate time difference for EST conversion
Assign - convertedTime = DateTime.Now.Add(timeDifference)
Log Message - "Converted time in EST: " + convertedTime.ToString("yyyy-MM-dd HH:mm:ss")
Else:
Log Message - "System time zone is already EST: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")