There's no way built into Date itself. I don't think it's part of the JS spec?
Date
If it is then show me where and I'll be happy to add it to Espruino though.
You could change the timezone globally just while you access date:
var tz = (new Date()).getTimezoneOffset(); E.setTimeZone(6); var d = new Date(); // access date here E.setTimeZone(tz/60); // return to default
But IMO the most sane thing is just to add/subtract what you need from the hours:
var timezone = 1; var d = new Date(Date.now()+timezone*3600000); print(new Date(), d) // Date: Wed Jul 1 2020 08:14:48 GMT+0000 // Date: Wed Jul 1 2020 09:14:48 GMT+0000
It'll still report GMT+0000, but everything else is as you want it
GMT+0000
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
There's no way built into
Date
itself. I don't think it's part of the JS spec?If it is then show me where and I'll be happy to add it to Espruino though.
You could change the timezone globally just while you access date:
But IMO the most sane thing is just to add/subtract what you need from the hours:
It'll still report
GMT+0000
, but everything else is as you want it