Hi,
I’m completely new to Pega robotic process automation so I would like to ask if there is a way on how to change or set the timezone using datetime utility perhaps?
Hi,
I’m completely new to Pega robotic process automation so I would like to ask if there is a way on how to change or set the timezone using datetime utility perhaps?
@RodelD25 I am not quite sure what you are asking for. Would you be able to give me an example? Are you trying to change the time zone on the local machine, or are you converting a DateTime object from one time zone to another (or something else perhaps)?
Hi @ThomasSasnett I’m trying to convert a local time in my machine into a different time zone. For example my current time zone in my machine is in Asia Pacific and I want it to convert into Central Standard Time in the bot rather than changing the time zone itself in the machine. This way whoever uses the bot and whatever time zone is in their local machine it will always be converted into the time zone set in the bot.
@RodelD25 Here is an example. You need to add some static methods from the Global Assembly Cache. To do that;
In my example, I am using a DateTimeUtils to get the current time using the Now method. I then call the FindSystemTimeZoneById method which returns a TimeZone object for the specified Id. You’ll have to search for these IDs, but I did include the one you asked for. Then I converted it to UTC so that I could then convert it from UTC. This is really just for the automation. In code, you would just do this directly, however I would need to create a TimeZone object for the current time which would be more automation steps.
Project77.zip (14.9 KB)
@ThomasSasnett thank you so much for your help.