Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Date format not supported? MM/DD/YY hh:mm

Issue

As an user, I'm having trouble getting the desired format of MM/DD/YY hh:mm. The format MM/DD/YY works, but not with the time. I need to surround the JS expression in mustache brackets {{...}} for it to evaluate properly in widget property fields.

Resolution

To display the format MM/DD/YY hh:mm, you need to surround the JS expression in mustache brackets. This ensures that JS evaluates properly in the widget property fields. The format MM/DD/YY is already supported by most platforms, but the time part needs to be added separately.

Here's an example of how to display the date and time in the specified format:

{{new Date().toLocaleDateString('en-US')}} {{new Date().toLocaleTimeString('en-US')}}

This code will display the date in MM/DD/YY format and time in hh:mm format. You can customize the format by modifying the arguments passed to toLocaleDateString() and toLocaleTimeString().