Category: JS Objects
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

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:

moment(new Date()).format('MM/DD/yyyy HH:mm')

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 format(). You can find a cheatsheet for momentjs here.