I’m stuggling to do some date manipulaion. I need to stipulate 2 dates, get the difference between them and then subtract that difference from today’s date.
I’ve done this in JavaScript, but in K6 I’m having issues with the date format.
The dates in question span a daylight saving time change, so to get around this we need to convert the dates to UTC to get rid of the DST first then get the difference between them.
This works fine now. Returns 15911.
So it’s the last Step i’m struggling with. I need to subtract the number of days (diffdays) from today and get a date with dd/mm/yyyy format.
If today is 19/03/2021 the answer I’m looking for is 26/08/1977.
Update
day = 1000 * 60 *60 * 24
date3 = Date.now() - ( day * diffdays)
returns the correct unix time, so I need to convert that to dd/mm/yyyy
So I’ve managed it, but this seems quite long-winded.
I maked some extension like pet project, maybe in this extension rnow() function it’s what you need.
But is not official extension))) and i didn’t use it in my job projects yet. But you can tried.