How to change date time format of date picker field in custom node

Describe the issue/error/question

Hello, I am working on a custom programatic style node.

For a search operation, I want to send a “From” date parameter in my query string, which accepts this format: YYYY-MM-DDTHH:mm:ssZ.

This is the date picked in date picker field:

image

Below is the output. I don’t understand why the day is 1 day before the date picked above and the time also seems off.

image

My question is: How do I preserve the exact date picked in date picker and format it to ISO 8601 (without fractional second part) in UTC, like shown below:

image

Share the output returned by the last node

image

Thank you!

Hm, perhaps our chief node builder @marcus can help with this one? Outside of nodes I’d simply use Luxon for my timestamp formatting needs, though not sure if this would be a feasible option for the date time picker as well.

Hi @alexnemes,
you could use moment.format() to get ISO 8601 with no fractional seconds like this:

1 Like

Hi @marcus thank you for your response. It works now :slight_smile:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.