Update the perspective date component as per system date

The perspective date component needs to be updated based on the system date i.e. regional format and country.
Do we have any functions or scripting to get the work done in perspective?

Any of the system.date functions return localized dates so long as the locale is set appropriately.

Any of the Date expressions should also return the localized date.

Uhm, no. They return instances of java.util.Date, which carry neither localization nor time zone themselves. Localization is applied from the VM state when converting to/from strings.

Some of Perspective's various components can take dates delivered to the front end in UTC millis format (the underlying format of java.util.Date) and apply the browser's localization. For all else, since Perspective's scripts run in the gateway, the script author must deliberately work with java's timezone objects initialized from the session's timezone to perform string conversions correctly (manually).

1 Like

Hi all,
Is there any way to change timezone of gateway or perspective for testing purposes.
Like an example: The timezone which we are getting is ‘Asia/Calcutta’. Even After changing in the session paramter,browser timezone as well as system timezone it is still retuning the same timezone i.e, ‘Asia/calcuatta’.

Hi All,…Our requirement is to display the Date format according to system locale (en-us,en-uk etc) for different regions…Is this possible with Ignition’s available features/properties?

en-us —>02/22/2022
en-uk—> 22/02/2022
etc

Yes, your scripts can take the UTC milliseconds from the java.util.Date Ignition uses and make a java.time.Instant with its static method .ofEpochMilli(). Then, obtain a java.time.ZoneId, usuallly by lookup with .of(). With those two, you can obtain a java.time.ZonedDateTime with its .ofInstant() method.

That can then be formatted numerous ways, all respecting the given ZoneId.