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:

Angus, is there a way to pull data from a calendar date and use it separately within the composer

Right now, I have the user enter the date, a text field for the month, a date field for 1 week before the date entered.

For example, user enters date (format changed to MM/DD/YY).
let’s say 05/23/22

In the post title, I want to simply have it say the Month, for example wizard runs, title will result as:

Meeting in (field result:) Denver, May 2022.

Within the post, I want it to parse the data and display:

  • "23-May" in some places
  • May

Then I want it to subtract 1 week from the date, and post the previous Monday (7 days prior) to selected date. to display

  • "16-May"

Is there a way to do this from one date field, or do I just have to stick with requiring the things be entered separately in the wizard

hm you could perhaps pair the custom wizard plugin with the automation plugin to achieve this.

https://meta.discourse.org/t/discourse-automation/195773

I didn’t know about this plugin. I don’t think it’ll work for my use case as I just need three dates in a new topic which the wizard is generating. I just have to put in 3 dates to have it pre-format my topic.

I was hoping there’s some sort of built in logic to take input 1, then interpolate 2 other data points from it, and display all three as field content within the action of the wizard. Meaning the wizard interpolates and sets the variables based on (in my case a number of days prior to my input date).

That said, I’m going to explore this plugin as it might be useful for automating some of the repetitive tasks of creating Meeting record threads and specifically formatted responses that our professional association generates (manually) each month.