You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • 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:

    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

About

Avatar for Gordon @Gordon started