I have a date that comes to me in seconds. Example: 1699331904
I need to convert it to a date. Just the date, no time. Example 11/06/2023
Both of the expressions here resolve the expected values.
{{ $(‘Entry’).item.json[“devices”][“date_last_beat”] }} resolves to 1699331904.
{{ DateTime.fromSeconds(1699331904) }} resolves to Mon Nov 06 2023 20:38:24 GMT-0800 (Pacific Standard Time)
How do I put expression one in where I’ve included it’s value in expression two?
This does not work:
{{ DateTime.fromSeconds($(‘Entry’).item.json[“devices”][“date_last_beat”]) }}
Thanks in advance,
-Russ
Hey @russellkg,
you are nearlly there. You just need to format the date to your format.
{{ DateTime.fromSeconds($(‘Entry’).item.json[“devices”][“date_last_beat”]).toFormat('MM/dd/yyyy') }}
This should do the trick.
For me DateTime just works if I include the timezone in the .from…()-methods.
Thatswhy I need to include it like this:
{{DateTime.fromSeconds($(‘Entry’).item.json[“devices”][“date_last_beat”], {zone: 'utc'}).toFormat('MM/dd/yyyy') }}
Here is a working example:
Cheers.
1 Like
Awesome. Thank you so much.
Here’s the flow that worked:
One to the next one!
-Russ
2 Likes
system
Closed
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.