Hi,
Currently I'm building an app where I have a separate date and time picker and saved in a field where the data type is date and the other is time. So when I save it I use the BuildDateTime() function to form a datetime data but it automatically converts to UTC. I need to original date and time to be saved not the UTC. Any alternatives on this?
Screenshot below for the date and time separate picker:
Thank you in advance.
Why don't you save them separately?
Only DateTime gets converted. If you save Date and Time as two attributes, they stay with the value selected.
Or you can convert them to text and save as text.
Yeah, correct, they are both good approach.
I add one more point that Outsystems will auto convert the timezone forward to server one to save and backward to client timezone to load. Its already good practice if your application serves more timezones. I think you don't need to save the local timezone and leave it an extensibility to use in many timezones. To achieve that you can convert your 2 fields to 1 DateTime on client and pass to server action to save
This is what I did. Thanks for the help! I appreciate it!
Hello,
Right before saving to the table, you can add hours to the DateTime you built by using AddHours(DateTime, RegionHours).
For example, if the region is Egypt, you would add 2 hours: AddHours(DateTime, 2).
Hello Ice,
for your use case, I would like to suggest to use a forge component to convert UTC back to your/user timezone, It has all these functions to convert from/to UTC and works flawlessly. Below is the snap from my app:
It is called Time Zone service, following is the link for same: https://www.outsystems.com/forge/component-overview/11419/time-zone-service-o11
Cheers.