Hello there, I am using Outsystems Service Studio 11 to develop a mobile application. 

I am fetching data from our server database using an aggregate. This data includes a date time field. When I display this information on a screen, it seems to modify the time and add two hours to it.

The format of the time fetched is in dd-MM-yyyy hh:mm:ss. I'd assume Outsystems would define this as UTC timezone. I am physically in East European Summer Time (UTC+3) Timezone, so it doesn't make that much sense. Either way I need the time to be displayed as I have fetched it. 

How should I go about this?

Hi Mia!

There are components in OutSystems Forge that give you options to display time for your server's time zone.

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

Another option would be to use the built-in functions under Date and Time such as AddHours().

Kind regards,
Joseph Enriquez

Hey Joseph, 

Thanks for the reply. I am currently using your second suggestion, however it is looking pretty complicated for such a simple task. I'm looking to get a time in the format 00:00 without the seconds.

This was my first version:

However results ended up like : 9:0 , 23:0, and 6:15. Which is very messy and not as easy to read.

So I included this:

And this gives me the result I want like : 09:00, 23:00, and 06:15. I was just wondering is there no way to make this more efficient? I'm not sure which of the methods in the component you linked would help. I just want Outsystems not to modify the data without me telling it to.


Kind Regards,

Mia


Edit: When uploading a file it adds two images and it seems when I delete the second copy it disappears from the post completely...

Hi Mia!


As quoted by Joseph, you can use time zone, know more this article.


Hope it helps you.

Regards, Marcilio Ferreira.

Mia Lahtinen wrote:

Hey Joseph, 

Thanks for the reply. I am currently using your second suggestion, however it is looking pretty complicated for such a simple task. I'm looking to get a time in the format 00:00 without the seconds.

This was my first version:

However results ended up like : 9:0 , 23:0, and 6:15. Which is very messy and not as easy to read.

So I included this:

And this gives me the result I want like : 09:00, 23:00, and 06:15. I was just wondering is there no way to make this more efficient? I'm not sure which of the methods in the component you linked would help. I just want Outsystems not to modify the data without me telling it to.


Kind Regards,

Mia

Mia, you can use a function :

SyntaxEditor Code Snippet

FormatDateTime(,)


He need two paramets

1) your value (date)

2) format: hh:mm


Hope it helps you.

Regards, Marcilio Ferreira.

Marcilio Ferreira wrote:

Mia Lahtinen wrote:

Hey Joseph, 

Thanks for the reply. I am currently using your second suggestion, however it is looking pretty complicated for such a simple task. I'm looking to get a time in the format 00:00 without the seconds.

This was my first version:

However results ended up like : 9:0 , 23:0, and 6:15. Which is very messy and not as easy to read.

So I included this:

And this gives me the result I want like : 09:00, 23:00, and 06:15. I was just wondering is there no way to make this more efficient? I'm not sure which of the methods in the component you linked would help. I just want Outsystems not to modify the data without me telling it to.


Kind Regards,

Mia

Mia, you can use a function :

SyntaxEditor Code Snippet

FormatDateTime(,)


He need two paramets

1) your value (date)

2) format: hh:mm


Hope it helps you.

Regards, Marcilio Ferreira.

Hey thanks for this Marcilio,

I was looking in the wrong area of the Built In functions it seems. The format HH:mm was what I used since I needed 24H. This helped a lot.


Going back to the Timezone conversation and my current solution, I started thinking if the user is in a timezone that would add 1 more hour to the time, then the data fetched from the database would have 3 hours added to it, and the AddHours(,-2) wouldn't be accurate anymore.

Where is the date being modified? Is it when the server is fetching the data? Or when the server sends it to the client? 

I apologise if I am being daft, or difficult, but it seems a bit redundant if the logic flow goes : Take data from DB > Modify to Client's TZ > Change back to original TZ. 

Kind Regards,

Mia


Hello Mia Lahtinen,


The easy way to show the Date Time as it's in the database is by converting the data time in two attributes (one Date and one Time). This two attributes should be retrieved by server side.

When you are fetching the data time that is in database (in server side), but using in client side the date time is converted to the timezone where the device is. This only occurs when using date time.

By using Date + Time, the date time is correctly shown in every devices and in every time zones. No need to add hours. 


The same happens when using CurrDateTime():

https://success.outsystems.com/Documentation/10/Reference/OutSystems_Language/Logic/Built-in_Functions/Date_and_Time

you can read that:

CurrDateTime()In client-side calls, it returns the device date and time.
In server-side calls, it returns the platform server date and time.
In query calls, it returns the platform server date and time.

Date times in the device are converted in the server to the server time zone.
Conversely, date times in the server are converted in the device to the device time zone.


EFreitas wrote:

Hello Mia Lahtinen,


The easy way to show the Date Time as it's in the database is by converting the data time in two attributes (one Date and one Time). This two attributes should be retrieved by server side.

When you are fetching the data time that is in database (in server side), but using in client side the date time is converted to the timezone where the device is. This only occurs when using date time.

By using Date + Time, the date time is correctly shown in every devices and in every time zones. No need to add hours. 


The same happens when using CurrDateTime():

https://success.outsystems.com/Documentation/10/Reference/OutSystems_Language/Logic/Built-in_Functions/Date_and_Time

you can read that:

CurrDateTime()In client-side calls, it returns the device date and time.
In server-side calls, it returns the platform server date and time.
In query calls, it returns the platform server date and time.

Date times in the device are converted in the server to the server time zone.
Conversely, date times in the server are converted in the device to the device time zone.


Hello EFreitas,

Thank you for this suggestion. I immediately attempted to modify the aggregate I was using the fetch the data, however I came across the issue that the date would be modified from "dd-mm-yyyy" to "mm-dd-yyyy". Any idea why this could be happening?

I tried using FormatDateTime(), but it's not possible. I've included a screenshot showing what the original datetime looks like and the DateTime to date looks like.

And here is the error I get for using FormateDateTime()


Thanks for any more help.

Hello Mia,

I'm not sure why your datechanged from "dd-mm-yyyy" to "mm-dd-yyyy".

Independently of that behaviour, you can use FormatDateTime in the screen and you will get the date formated as you want.