How to format date like this?

Hi @th3liam, I hope you’re having a good day?

For the transformations you have described I’d suggest using Luxon inside a Set node over the Date & Time node. This is because the Date & Time node would not be able to mix an date (like 2022-05-26 in your first example) with a pre-defined string like T00:00:00Z.

This is how a Set node returning today’s date in your desired format could look like:

In this example I am mixing an expression using Luxon to get today’s date (that’s the part inside {{ and }}) with the hard-coded part T00:00:00Z:

The second part could look very similar. Assuming you want to use the current time, your expression could look like so:

{{ $now.setZone('UTC').toFormat('yyyy-MM-dd') }}T{{ $now.setZone('UTC').toFormat('hh:mm:ss.SSS') }}000Z

The one thing Luxon does not support from the looks of it are 6-digit fractional seconds. So this example only uses milliseconds (indicated by SSS) and then adds three 0s. Hope this still works for you!

3 Likes