Join the Team Forms community

Updated 7 months ago

Date field output showing different format when selected

At a glance

The community member Kiki is experiencing an issue with date fields in a form. The default output string is in UTC timezone, but when a date is selected from the calendar, the output string changes to a different ISO 8601 format. This inconsistency causes problems when the output is processed in Power Automate. A community member suggests using the "Custom Default Value" setting in the data tab and provides two JavaScript examples to set the value in the desired format: value = moment().format() or value = moment().startOf('day').format().

When using date field in a form, default output string is in UTC timezone, example: 2024-07-11T04:52:11.000Z. However when a date is selected from calendar output string changed to different ISO 8601 format, example: 2024-07-11T00:00:00+10:00.

When this output is processed in Power Automate, it become inconsistent (could be a day different).

Can we have a consistent date string when the date is defaulted or selected from calendar?

Thanks,

Kiki

Marked as solution

Hi Kiki,

When setting the default date setting using moment() this will unfortunately return the current date in UTC.

However, you can work around this by using the "Custom Default Value" setting available in the data tab. The following JavaScript should set the value in the desired format:

value = moment().format()

Alternatively, if you want no time component you might be able to do something like this (note this is untested)

value = moment().startOf('day').format()

View full solution
A
1 comment

Hi Kiki,

When setting the default date setting using moment() this will unfortunately return the current date in UTC.

However, you can work around this by using the "Custom Default Value" setting available in the data tab. The following JavaScript should set the value in the desired format:

value = moment().format()

Alternatively, if you want no time component you might be able to do something like this (note this is untested)

value = moment().startOf('day').format()