Solution on how to convert DateTime variables between UTC and Local or a specific timezone

  1. Convert from UTC to a specified timezone.
    We can use the TimeZoneInfo.ConvertTimeFromUtc static method in an Assign activity (Invoke Method can work as well), setting first parameter to the UTC DateTime object and the second parameter to a TimeZoneInfo object which represent the target Timezone. The TimeZoneInfo object can be created with the help of TimeZoneInfo.FindSystemTimeZoneById method where we need to specify the name of the timezone we want, like India Standard Time or Tokyo Standard Time.

  2. Convert from a specified timezone to UTC
    We can use the TimeZoneInfo.ConvertTimeToUtc static method in a similar way as above, just that the second parameter is used to specify the source timezone. Note: the source DateTime object must have the Kind property set to DateTimeKind.Unspecified.

Please check the attached workflow or project to see how to use the above methods to convert the result of an activity from the Cron Expression package.
CronToLocalTime.xaml (15.2 KB) (7.0 KB)
The project was created in UiPath Studio 2019.10.2 and it references the UiPathTeam.CronHelper.Activities package which can be found in the Go! feed or on UiPath Go!. The project contains a single workflow, the one attached here. In case you can’t open the project, download the workflow and add it in a new project and reference the UiPathTeam.CronHelper.Activities package.

This post was created to answer a question for the Cron Expression component available on UiPath Go!

1 Like

Since, my current cron expression is based upon to run on IST (+5:30 GMT) timezone…in which zone is it returning the next run time. PFA screenshot from VM which is in PST timezone(-8:00 GMT)

Hi, can this be considered as a FAQ (and maybe moving to that forum category)?

Can we have activity where we input 2 params: TimezoneInfo and cron expression and it gives output in that particular timezone time.

@devashish1989, the activity is returning the next run time in UTC timezone. But the time expressed in the cron expression is interpreted as Local Time. I’m considering your suggestion to update the activity with the Timezone info as well, but it will take some time to do it.
For the moment, you can write the Cron Expression considering the time difference between your local Timezone and the desired Timezone (IST) and then convert the resulting time to the desired Timezone (IST).

Yes, maybe it fits better the FAQ section, thanks for the suggestion. I can’t move it myself, but maybe an admin can help.

1 Like


I am working on convert timezone. In my workflow I have captured system date and time. And I need to convert it into CST format.
Could you please help me on this.

Hi @vaishnavi_baradkar,

You could use the TimeZoneInfo.ConvertTimeFromUtc method to convert to the CST timezone. BTW, what is CST? Central Standard Time, China Standard Time?
But, for that you need to capture the current time in UTC format using the DateTime.UtcNow property.

Here you have an example on how to do that: CurrentTimeToSpecificTimezone.xaml (5.9 KB)