I am trying to use date/time node in workflow to get previous date by using subtract time operation of 1 Day. Source date format DD/MM/YYYY and expecting previous Date in DD/MM/YYY format. I am not seeing the correct previous date.
source date 01/03/2024
previous date 28/02/2024
was expecting previous date as 29/02/2024
Any issue here?
If I set my time zone to “UTC” in the node, I do get the expected behavior (01/03/2024 minus one day gives 29/02/2024), but if I set it to “America/New York”, I see what you are talking about - I get 28/02/2024.
However, it’s not a leap-year-specific problem; if I subtract one day from 04/03/2024 with a time zone of “America/New York”, I get 02/03/2024.
I’m looking into this further. Thanks for bringing it to our attention.
If it is a 1 day operation, time zone shouldn’t matter at all. Is it not?
I talked with our engineering team and here’s what’s going on:
When setting the Timezone property in the node, you are setting the timezone of the output, not the input date. Note that you can define the timezone of the input date by appending it to the value you provide (i.e. “2024-03-01T00:00:00Z-04:00”). If no timezone is provided in the input, the input is assumed to be UTC.
So, when you provide an input of “01/03/2024”, that is resolving to “2024-03-01T00:00:00Z” (UTC).
Subtract one day and you get “2024-02-29T00:00:00Z” (UTC).
But if you set a time zone of, say, “America/New York”, that then becomes “2024-02-28T19:00:00Z-05:00”.
And your output format is “DD/MM/YYYY”, so what you’re left with is just “2024-02-28”.
Hopefully that makes sense. I’ve filed a ticket to clarify this behavior in the node’s editor as it confused me as well. Thanks for bringing this to our attention.