Missing date shift in {{formatDate val formatStr}} before formattting?

Unless I missed in ‘accessing payload data’, how do you shift a currentDateTime like in subject expression before the momentjs formatStr? That too inclusive of DST for a given US timezone.

Ex, I’d imagine you want formatStr to be something like - 'ddd MMM D, YYYY HH:mm:ss.SSS [GMT]-05:00'
To get the native format that’s on the Payload -
image

With the full expression being -

{{currentDateTime 'ddd MMM D, YYYY HH:mm:ss.SSS [GMT]-05:00'}}

However this returns GMT (doesn’t shift to EST), which is confusing because the formatStr puts the “-05:00” stamp on it…

Beyond that, is there more documentation on {{formatDateRelative date relativeTo}}, such as being able to use currentDateTime and options like “5 hours ago”?

The {{currentDateTime}} and {{formatDate}} helpers do not support providing a timezone offset; we have an open feature request for that and I will add your +1 to the request.

The underlying value on the payload is actually a JavaScript Date object; the format you are seeing in the payload preview is the result of the toString() method being applied to the object client-side (in your browser). For example, if you ran the following in a Function Node …

console.log(payload.time.toString());

… the output would include no offset, because the operation is happening on Losant’s servers outside the context of a timezone:

Thu Jan 04 2024 21:32:25 GMT+0000 (Coordinated Universal Time)

One thing you could do, in a workflow, is use the Date/Time Node to get the result you are looking for.

Format string used here: ddd MMM D, YYYY HH:mm:ss.SSS [GMT]Z

1 Like