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 Timeor
Tokyo Standard Time.
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)
CronExpressionTimezone.zip (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.