Fancy Date Expression

Fancy Date Expression

The Date_PretyFormat is a great epression tool to display a user friendly date aspect. My issue is that being from Australia, the Date_PrettyFormat shows the expression "Tomorrow" when a new record is created. I suspect this is due to the timezone (+10). Is there a way to localise the time for my espace and/or server (My apps are hosted with Outsystems). It can be very frustrating to view the error logs to troubleshoot issues, and have to count forward the time difference.

Has anyone got a fix for this?




I am curious about the fact "My apps are hosted with Outsystems". Do you mean that your apps are located on a server in Portugal?
(which kinda explains the time issue) or do you have your own servers in Australia?
Hi Robbie,

This happens probably because you are passing a database DateTime to the "Date_PrettyFormat" function that is comparing with the Front-end Server DateTime.
If the timezones are different you'll need to do the Math (transform the DB DateTime passed to the function) to align those values.

Edit: You can use the function "CurrDateTime()" to check the Front-end Server DateTime.

Thanks for the replies guys.

Joost - My apps are hosted with Outsystems. i will soon be moving to Australian servers, which then have the correct time zone for my Australian based customers.

HD - i have created an Entity called "UserDetails" which stores the user's timezone. i am also using the timezone reference in my app. So the date stored in the database is the local time for the user.

Does this mean that the Date_PrettyFormat compares the input date with the date of the front-end server? This is going to be a problem, so long as the apps are stored in a different time zone.

Robbie Nati wrote:
Does this mean that the Date_PrettyFormat compares the input date with the date of the front-end server?
Yes. In the typical "use case" DB and FE Servers are under the same timezone. This means that in your case you'll have to use the AddHours(..., 10) in every Widget input DateTime... or create a wrapper widget and you only have to do that once. :)
Hi Robbie,

If you can't control for now the timezone of the front-end, I'd suggest:

- adding a site property with the timezone of the front-end;
- adding an action (marked as function - ex: MyPrettyDateFormat) for formatting the date, taking into account the mentioned site property;
- then replacing (using Find and Replace...) all Date_PrettyFormat occurrences for MyPrettyDateFormat.

When you move to Australian servers, no worries, you'd just have to update the site property. :)

Paulo Ramos
Thanks Guys. I agree Paulo, thats what i had in mind. That way, It wont matter where the apps are hosted, the dates can be managed on a "site" or "tennant" basis.
Thanks again for everyone's input.