User-dependent date format

User-dependent date format


Hi All,

We have an application which now needs to support international user-dependent date formats. This means date fields shown to the user will depend on his/her locale.

The date format configuration in Service Center works system-wide and is thus not suitable for this requirement. Do you know any simple way to implement this? I know we could search for all the date occurrences in our screens/blocks and filter them through a date-formatting function but this would be quite error-prone (and boring also :)!)

Thanks for your help,


Hi Rui,

I don't have good news :). Date/time handling and localization is a bit of a pain in the Platform. Apart from what you already suggested I don't have a solution.

Hi Kilian,

Thanks for your input - going through the code manually and using a date-formatting function seems to be the solution.



Hi Rui,

I played around with this problem a while ago and sort of got a solution...

The trick is that it becomes the BROWSER that must decide what time actually gets displayed based on its locale.  The server handles all times in UTC.

This conversion can be simply arranged with the following javascript code if we make the server supply the UTC time in the ISO standard format:  var localTime = new Date(utc);

To make this easier to use I tried the following:

Step 1: Create an IsoTime(utc) server action to return a specified (UTC) DateTime value directly as an ISO format text string:
I used Text.formatDateTime(utc, "yyyy-MM-ddTHH:mm:ssZ")

Step 2: Create a WebBlock with an Expression with value:
   "<script>document.write(localTime('" + isoTime(utc) + "'))</script>"
where utc is a DateTime input parameter to the WebBlock

Step 3: In the WebBlock JavaScript add:
   function localTime(utc) { return (new Date(utc)).toLocaleString(); }

This works until we want to refresh the time with an AJAX call.  AJAX will not execute the script.
Apparently there are ways around this by using a one bit image with its onLoad= set to our javascript but this sounds very awkward and messy.

Also it becomes awkward to format the time (javascript does not appear to have any nice formatting functions that I am aware of so I just used the current locale formatting).

At the end of the day, I sighed and resorted to setting a Site TimeZone offset which I added to the current time before displaying.  I'm still new to all this so perhaps there is a way to make things simpler but hopefully this can at least give you a hint of what can work.

Cheers, Lester


The Platform servers run in local time, and I've never encountered UTC supplied dates, except from external web services. Indeed, recently on this forum someone had the problem of running of an Amazon server located in the US, while working in Europe, and having wrong timestamps because of that.

Also, the OP asked about date/time formatting, not UTC offset conversion.

Good points Kilian - I should read things a bit more carefully.

Nevertheless, using this technique (ensuring the server time is converted to UTC before rendering the page) does allow his local times to be formatted according to individual browser locale.


Thank you all for your input! My question's main concern was to find a way to easily and quickly format all date strings (without the hh:mm part) across an entire application depending on the user's preferences (locale).

Until now, it looks like there is no way around manually changing all expressions on all web screens/blocks and filter the date fields through a formatting function.