There are still issues with the UTC variable. The system variable is now the correct value, but when you go to display it, it shows as the local time. See the attached test piston, the output, and the system variables.
So Time in webcore is always the same. ie the internal representation of time now is now as a number.
When you print it out, is when you can see what an instant in time is in a particular timezone.
the function formatdatetime takes optional arguments to select the TZID you want to format a time string as.
https://wiki.webcore.co/Functions#formatDateTime
so
formatdatetime(date,format) just lets you control what is shown (using the Hub's TZID)
you can add a 3rd argument:
formatdatetime(date,format,tzid) to show
you can see tzid formats:
https://www.unicode.org/cldr/charts/43/supplemental/zone_tzid.html
Also note you can change a piston to operate in a different timezone than the hub's
you would use the function: settzid(tzid)
That's confusing. For a variable, I would expect that variable to be correct regardless of the timezone I'm in. For example, $month tells me the current month, $now tells me my current time. I would expect $utc to tell me the UTC time correctly at GMT. But if not, is there a variable that does tell me the current time at GMT, which is really what I want.
you can use
formatDateTime($now, "yyyy-MM-dd'T'HH:mm z", "GMT")
so
2024-02-06T04:33 GMT
will print out the current time in GMT.
Or you can
formatDateTime($now, "yyyy-MM-dd'T'HH:mm z")
will get you
2024-02-05T23:33 EST
which is because the piston is defaulting to the hub's timezone (EST)
Note this is the same time, just printed out for different timezones. They are not different times...
If you want your piston to operate in GMT
setTzid("GMT")
within that piston and then things will give you $day, $hour as GMT in that piston.
setTzid returns the previous timezone id, in case you want to save it for restoring it later.
There are variable for $tzOffset if you want to know what is your piston's offset from GMT