Displaying dates and time using JS
toLocaleString(locales, options)
<script>
// Displaying the current date (PDF generation date) using French conventions.
//
new Date().toLocaleString('fr-FR');
//=> "25/10/2050, 12:34:56"
// Displaying a date provided in your Document payload using US conventions.
// Sample payload
// { "someDate": "2050-10-25 12:34:56" }
//
new Date($docPayload.someDate).toLocaleString('en-US');
//=> "10/25/2050, 12:34:56 PM"
// Displaying a date using en-US conventions in a custom timezone.
//
let date = new Date(Date.UTC(2050, 1, 1, 12, 34, 56));
new Date(date).toLocaleString('en-GB', { timeZone: 'Pacific/Honolulu' });
//=> "01/02/2050, 02:34:56"
</script>Using a library
Last updated
Was this helpful?
