Different Time between Portugal and Indonesia

Different Time between Portugal and Indonesia

  

Hi there,

I am wondering when doing the Movie assignment, this is the database in personal cloud:

when i run the application, it shows like this:

How come, it can  shows my local (Indonesia) time?... I know the difference between both countries are 7 hours.. so 18:00:00 + 7 become 01:00 ..and the format is:

Can i use as is... i mean... still in Portugal's time?

regards,

indra

Hi Indra Budiantho, you cannot change this configuration. You will need use a extension to format your Date.
Look at https://www.outsystems.com/forge/component/500/time-zone/

Hello Indra,

This is a very interesting topic.
In the mobile documentation is stated that when a Date Time is sent to server from mobile, it is automatically converted between the time zones, while when comming back from the server to mobile, it is converted back. This means that the Date Time will alwys be stored using the Timezone of the Server.

This solves some difficults we have in Web, but causes others, mainly when you need to keep the value without the conversion. 

In order to workaround this if yo udon't want the conversion, a possible approach, that I didn't tested (as I'm without access to a Service Studio right now), would be to use separate fields for the Date and the Time. I'm not sure, but I expect that when stored separately, this automatically conversion would not occur.   

There are other workarounds, like storing the DateTime as text, as difference of seconds from a predefined date, etc, but all of them will require extra logic, harder than the one required to put together (if needed) Date and Time. 

Cheers.
Eduardo Jauch

Hi, Paulo,

Thank you,

I have installed that.

regards,

indra 

Eduardo Jauch wrote:

Hello Indra,

This is a very interesting topic.
In the mobile documentation is stated that when a Date Time is sent to server from mobile, it is automatically converted between the time zones, while when comming back from the server to mobile, it is converted back. This means that the Date Time will alwys be stored using the Timezone of the Server.

This solves some difficults we have in Web, but causes others, mainly when you need to keep the value without the conversion. 

In order to workaround this if yo udon't want the conversion, a possible approach, that I didn't tested (as I'm without access to a Service Studio right now), would be to use separate fields for the Date and the Time. I'm not sure, but I expect that when stored separately, this automatically conversion would not occur.   

There are other workarounds, like storing the DateTime as text, as difference of seconds from a predefined date, etc, but all of them will require extra logic, harder than the one required to put together (if needed) Date and Time. 

Cheers.
Eduardo Jauch


Hi Eduardo,

I am still curious about some issues:

1. The timezone is stored using the Timezone of the Server. How do i know what Timezone the sever has?

2. When i display the timezone in my device/my web, how the platform knows which timezone my device has? How it works?

3. For local database (local storage), how does it behave?

4. What is the best practice (pattern) to use this timezone for end users with different timezones? In my country, Indonesia there are 3 time zones: east, middle, and west with one hour margin consecutively.    

Thank you,

regards,

indra

Solution

Hi Indra,

If datetimes are generated from your device, and you store them in Database entities, they will be converted to the Server timezone automatically. The same way, when you use a datetime from a Database entity on your device, it will automatically be converted from the server timezone to the timezone of the device. This was put in place to guarantee that dates are always stored in the same timezone (and can be compared without issue), and users always see datetimes in their own timezone.

The problem you are facing with the MovieSession data read from the excel file, is that it didn't go through the device, and as such no conversion process took place. The best alternative for you would be to, on the bootstrap logic, convert them (using the TimeZone module, you can safely ignore the TimeZone extension on the Manage Dependencies window) from your timezone to the server timezone. That way you again guarantee that datetimes in the Database entities are stored properly.

1. The server timezone is configured by the server administrator it's a predetermined value for on premises servers. For the cloud environments, if you open ServiceCenter you will be able to see what is the current time in the Server's timezone.

2. It is possible to know the timezone configured for the device via JavaScript. I don't know exactly how it is implemented, but on a web page you can use something like the getTimezoneOffset() of a JavaScript Date object to know what's the timezone... with that information you can do the conversions.

3. On the Local Storage, I'd say you don't have any conversion, as the date is already in the correct timezone for the user.

4. That will depend on what you need. If I'm not mistaken, by default Mobile Apps will show datetimes in the user's device timezone (so if your users are in different timezones, they wouldn't see the same value for the datetimes, they'd see datetimes shown relative to their specific timezone), whereas Web Applications will show datetimes in the server's timezone. If you want something different from this, you will need to convert dates using the TimeZone component (on the Server-side) or using the methods of the JavaScript Date object (or maybe using one of Eduardo's suggestions).

Hope this helps

Solution