330
Views
19
Comments
How to add 3+ hours to my server time?


Hi

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

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

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


UserImage.jpg
Faris Abdullah Almozini

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


2021-08-12 11-00-27
Nordin Ahdi
 
MVP

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

UserImage.jpg
Faris Abdullah Almozini

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




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

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

You just have to convert between UTC and AST.

UserImage.jpg
Faris Abdullah Almozini

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


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

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.

UserImage.jpg
Faris Abdullah Almozini

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

2021-08-12 11-00-27
Nordin Ahdi
 
MVP

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

UserImage.jpg
Faris Abdullah Almozini

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

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

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.

UserImage.jpg
Faris Abdullah Almozini

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


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

Hello.

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

TimeZone.oml
UserImage.jpg
Faris Abdullah Almozini

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.


2021-03-18 21-03-15
Benjith Sam
 
MVP

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

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

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.

2020-08-19 00-21-59
Tom Nogueira

Faris Abdullah Almozini wrote:


Hi

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

 

 Hello Friend,


You can try put in Assign this command to your variable: AddHours(CurrDateTime(),-3)

UserImage.jpg
Faris Abdullah Almozini

Tom Nogueira wrote:

Faris Abdullah Almozini wrote:


Hi

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

 

 Hello Friend,


You can try put in Assign this command to your variable: AddHours(CurrDateTime(),-3)

 which variable you mean? do I have to create one for the date or just added to the enitity

 

2019-09-24 18-41-25
Jorge Martins
 
MVP

Hi Faris Abdullah Almozini and Tom,

@Tom, Your suggestion is similar to what Benjith suggested above (and the correct is, like he mentions, to add +3h, since Faros' timezone is UTC+3), you may want to check Nuno's thoughts on the downside to do it that way, they are spot on.

@Faris Abdullah Almozini, are you still facing this issue after 2.5 months??

Since you seem to be creating a Mobile app (the same applies to Reactive apps btw), you shouldn't have to worry about timezones when using CurrTime() or CurrDateTime() at all:

  • on Client actions and Screens, Time and DateTime data types always represent time in the device's timezone
  • on Server actions, Time and DateTime data types will always represent time in the server's timezone
  • when a Time or a DateTime value is passed from Client to Server (or from Server to Client), OutSystems will automatically do the right conversion.

The Timezone component is useful when, in your Server actions, you want to perform calculations with Time and DateTime values from multiple timezones (Nuno's info is quite complete, if this is what you need, just read it and see how the sample page was implemented on the Timezone component itself)

Hope this makes things clearer!

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