Time Zone Task _ Help

Hi Team,

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.

Thank you

Hi @manikandan.murugan

Try this:

Assign → systemTimeZoneInfo = TimeZoneInfo.Local
Assign → targetTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time") 

If → systemTimeZoneInfo.Id <> targetTimeZoneInfo.Id
    Assign → estTime = TimeZoneInfo.ConvertTime(DateTime.Now, systemTimeZoneInfo, targetTimeZoneInfo)
Else
    Assign → estTime = DateTime.Now

Log Message → "EST Time and Date: " & estTime.ToString("yyyy-MM-dd HH:mm:ss")

Note: “systemTimeZoneInfo” and “targetTimeZoneInfo” variables are of Data Type System.TimeZoneInfo and “estTime” variable is of Data Type System.DateTime.

Hope it helps!!

1 Like

Hi @manikandan.murugan

Welcome to Community!!

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")
1 Like

Hi @manikandan.murugan

Follow the below process steps

  1. Assign activity:
    Variable: systemTimeZone
    Value: System.TimeZoneInfo.Local

  2. If activity:
    Condition: systemTimeZone.Id <> “Eastern Standard Time”

    Then:
    Assign activity:
    Variable: estTimeZone
    Value: System.TimeZoneInfo.FindSystemTimeZoneById(“Eastern Standard Time”)

    Assign activity:
    Variable: estTime
    Value: TimeZoneInfo.ConvertTime(DateTime.UtcNow, estTimeZone)

  3. Log Message activity:
    Message: "Current time in EST: " + estTime.ToString(“yyyy-MM-dd HH:mm:ss”)

Check the below workflow
Sequence.xaml (8.3 KB)

Check the below image for output

Hope it helps!!

1 Like

Hi @Parvathy ,

It’s works for me and Thanks for your valuable time and help :grinning:

1 Like

Hi @mkankatala

Thank you so much for your reply and I tried it works and Thanks to you :grinning:

1 Like

Hi @lrtetala,

thank you so much for your help and I tried it works to me. :grinning:

1 Like

You’re Welcome @manikandan.murugan

Happy Automation

Regards,

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