Displaying dates and time using JS
PDFMonkey’s engine runs on AWS servers located in Europe. The timezone of the server might not be the one you want your dates to be displayed in.
On the Liquid side you can use the in_time_zone filter to set a timezone and the date filter to format a date. On the JavaScript side, you can use the toLocaleString
method.
toLocaleString(locales, options)
The toLocaleString method returns a string with a language sensitive representation of a date.
The locales
and options
arguments let applications specify the language whose formatting conventions should be used and customize the behavior of the function.
You can learn more about the toLocaleString method in its MDN documentation page.
Using a library
Paid account only
Using an external JS library will only work on a paid account. On a free account preview and generation will be blocked.
If you need the help of a more powerful library, you can always load the one you need. The most frequently used one it MomentJS but we recommend a more recent iteration of the same idea by the actual author of MomentJS. It's called Luxon and can be used as follows:
Last updated