16
Views
5
Comments
Solved
Alternatives for BuildDateTime() function that automatically converts to UTC?

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.

2016-04-22 00-29-45
Nuno Reis
 
MVP
Solution

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.

2023-10-16 05-50-48
Shingo Lam

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

UserImage.jpg
Ice Tube

This is what I did. Thanks for the help! I appreciate it!

2025-12-22 13-50-43
Sherif El-Habibi
Champion

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).

2020-07-29 19-08-40
Sanjay Kumar Sahu

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.

2016-04-22 00-29-45
Nuno Reis
 
MVP
Solution

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.

2023-10-16 05-50-48
Shingo Lam

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

UserImage.jpg
Ice Tube

This is what I did. Thanks for the help! I appreciate it!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.