Datetime_PrettyFormat and Timezone adjustment.

Got some headache with Datetime_PrettyFormat and Timezone adjustment.

Eg creation_datetime.

When adjusted for timezone differences (+/- some hours), after saving new record it does not show "(just now)" in List screen.

It seems my only options is to ditch Datetime_PrettyFormat() and go for FormatDateTime(), or create my own Datetime_PrettyFormat().

I really hope Outsystems will have better timezone support out of the box in the future.

Hi Harlin,

I agree outsystems should have better timezone support. What we do here in this situation is to save the creation date in UTC, but when retrieving the data we apply the timezone difference in the sql query itself so that we can apply datetime_prettyFormat functions while showing the results to the users who are present globally.


Hi Ravi,

I have already done that and it does works. 

However in Datetime_PrettyFormat there's 2 parts of visualization: the datetime and (just now) / (2 hours ago) / etc.

The second parts was compared with CurrDateTime() function which is in UTC.

So you will never got (just now) if your timezone is not UTC since the datetime you passed in parameter has been adjusted to another timezone = compared to CurrDateTime() in UTC.

Eg for timezone UTC -04:00

I have chat app, and everytime I send message I will see something like this:

01:32 (4 hours ago)   Hello... 

instead of:

(just now)   Hello... 

And it can get more weirder if time difference window is in midnight, it can show (a day ago), while it is actually (just now). 

I hope you understand what I meant. 


Hi Harlin,

I would suggest to write your own datetime_prettyformat java script function which will also consider the timezone offset instead of local date time. In the below example you would have to replace new date() with new date() +/- date offset. 

or another way is to open rich widgets espace (Clone) and copy the original source code of datetime_prettyformat function and modify as per your requirements.

function timeSince(date) {

  var seconds = Math.floor((new Date() - date) / 1000);

  var interval = Math.floor(seconds / 31536000);

  if (interval > 1) {
    return interval + " years";
  interval = Math.floor(seconds / 2592000);
  if (interval > 1) {
    return interval + " months";
  interval = Math.floor(seconds / 86400);
  if (interval > 1) {
    return interval + " days";
  interval = Math.floor(seconds / 3600);
  if (interval > 1) {
    return interval + " hours";
  interval = Math.floor(seconds / 60);
  if (interval > 1) {
    return interval + " minutes";
  return Math.floor(seconds) + " seconds";
var aDay = 24*60*60*1000
console.log(timeSince(new Date(;
console.log(timeSince(new Date(*2)));

Thanks Ravi...

Actually I had done the second option.

But your javascript code looks great, I'll try it.

Thanks a lot... 

I've also built the second suggestions for my projects. I've made a copy of DateTime_PrettyFormat and added a CurrDateTime input parameter and changed all the calls from CurrDateTime() to the input parameter. This way both the DateTime and CurrDateTime can be adjusted to be in the same timezone.