Handling Dates and Times

When using the date, time or date & time fields, it can be sometimes tricky to work out how the fields work. This topic is to handle any questions you may have.

How the format is used

The definitive guide on moment.js formatting is in the moment.js docs, however this is custom-wizard-specific explaination of how that applies, and a place for any questions about these custom wizard fields.

In the custom wizard code, the format you enter in the format input for a field is applied when the user updates the relevant field.

For example, if a time field format is set to the moment.js representation of an ISO 8601 date:

YYYY-MM-DDZHH:mm:ssZZ

If the user enters the time 07:00 in the time input on the 26th of November in the timezone of GMT+11 (Australia’s east coast, where I work from), the value that will be saved with the user’s submission will be

2020-11-26+11:0007:00:00+1100

In other words, moment.js will automatically fill out the date and timezone parts of the full ISO 8601 time according to what the user’s browser settings (i.e. when and where the user is).

:bulb: Pro Tip: if the format field is empty moment.js will automatically convert the input to an ISO 8601 string.

To further demostrate, if the format for the time field were changed to

h:mm a

and the user entered 07:00 again, the time saved would be

7:00 am

If you have any more questions about how the format is used to handle date and time inputs, please post below :point_down: