How to add 3+ hours to my server time?


Hi

My CurrTime() is 3 hours behind my local time, how to fix this?

Hello Faris.

You mean on the Cloud? That is standard.

In the OutSystems Cloud all servers are set to work in the UTC time zone. This configuration cannot be changed.

https://success.outsystems.com/Support/Enterprise_Customers/Maintenance_and_Operations/OutSystems_Cloud_and_time_zones

There are some pretty good workarounds,

https://www.outsystems.com/forge/component-overview/500/time-zone


Nuno Reis wrote:

Hello Faris.

You mean on the Cloud? That is standard.

In the OutSystems Cloud all servers are set to work in the UTC time zone. This configuration cannot be changed.

https://success.outsystems.com/Support/Enterprise_Customers/Maintenance_and_Operations/OutSystems_Cloud_and_time_zones

There are some pretty good workarounds,

https://www.outsystems.com/forge/component-overview/500/time-zone


Yup, I just need to add 3 hours more on it, I downloaded the timezone component but how to do it?

this's my timezone identifier: Arab Standard Time


Hi Faris,

The TimeZone component contains a sample page that demonstrates the time conversions. You can look into the logic to see how it is done.

Regards,

Nordin

The component includes an example and has all the actions you need.

You just have to convert between UTC and AST.

Nuno Reis wrote:

The component includes an example and has all the actions you need.

You just have to convert between UTC and AST.

Yes I opened the component but I don't how to use those actions I tried to copy it into my project but it won't paste


Nordin Ahdi wrote:

Hi Faris,

The TimeZone component contains a sample page that demonstrates the time conversions. You can look into the logic to see how it is done.

Regards,

Nordin

which action should I use for my problem

this one?

ConvertTimeZoneToIANA




Faris Abdullah Almozini wrote:

Yes I opened the component but I don't how to use those actions I tried to copy it into my project but it won't paste

Just to be clear, you don't "Copy". You add them as References.


You need ConvertFromUTC and ConvertToUTC.

The OS server is in UTC to be clear for everyone. Just like aviation uses UTC for all international communication to avoid different local time issues.

Nuno Reis wrote:

Faris Abdullah Almozini wrote:

Yes I opened the component but I don't how to use those actions I tried to copy it into my project but it won't paste

Just to be clear, you don't "Copy". You add them as References.


You need ConvertFromUTC and ConvertToUTC.

The OS server is in UTC to be clear for everyone. Just like aviation uses UTC for all international communication to avoid different local time issues.

I also did this multiple times but it does not show up on my project

Hi Faris,

The TimeZone extension is already added as a dependency in your module. You just need to click on the little arrow on the left for the actions to show up.

Regards,

Nordin

Nordin Ahdi wrote:

Hi Faris,

The TimeZone extension is already added as a dependency in your module. You just need to click on the litte arrow on the left for the actions to show up.

Regards,

Nordin

Wow sorry about that! I was looking at the server action :P

Ok, can you please tell me what to do now? I'm new to Outsystems

How to use ConvertFromUTC and ConvertToUTC and apply it to all the project

You have to:


Use the ConvertfromUTC function every time you wish to show a date to the user.

To do this I would create a block that converts input datetime.


Use the ConvertToUTC function every time you wish to save a user input date to the database.

To do this, configure your Create/Update actions to do the conversion and always use them instead of the default ones.


My first link has a lot of good resources.

Nuno Reis wrote:

You have to:


Use the ConvertfromUTC function every time you wish to show a date to the user.

To do this I would create a block that converts input datetime.


Use the ConvertToUTC function every time you wish to save a user input date to the database.

To do this, configure your Create/Update actions to do the conversion and always use them instead of the default ones.


My first link has a lot of good resources.

How to create a block that converts input datetime?

I created the block


Hello.

Sorry for the delay. I made a small example of the block in Reactive you can look at.

Nuno Reis wrote:

Hello.

Sorry for the delay. I made a small example of the block in Reactive you can look at.

No problem, I opened the file it seems like its for web app, will there be a problem if I use the block on a mobile app?

I used the block but still didn't make any difference, I would like to also mention that when I open the app on my device to shows the right time for a second than flip back to the server time.


Hi Faris Abdullah Almozini,

If your objective is to add +3 hours to the value obtained from CurrTime() function, you can achieve it by using the in-built AddHours() functions as mentioned below

Code Snippet

AddHours(CurrTime(), 3)


Note: AddHours() returns DateTime value so if you want to display only the incremented Time value you can wrap the AddHours() within the DateTimeToTime() function for value conversion as mentioned below

Code Snippet 

DateTimeToTime(AddHours(CurrTime(), 3))


See the sample app: DemoApp_UTC+3Hr


Hope this helps you!

Regards,

Benjith Sam

Faris

The idea is that you look at the logic and implement the way you need it.

Regarding the "going but to UTC", it should only recalculate if parameters changed. Are you sending new parameters?


Benjith, this is not a simple "add x hours" issue. This is a "different time zone" issue. The difference can change over the year. because of Daylight Saving Time.

Even if it would fix Faris issue, it could be misleading to others looking for the same.