Time settings in console.log ?

Posted on
  • hi are there any portion of information or code about espruino time settings what would be visible in console? I mean like you can see date, time, seconds etc.? was trying to use commands from http://www.espruino.com/Reference reference section but unsuccessful
    I could see from this eg. http://www.espruino.com/Pico+Clock#line=­3,11 date (Thu Jan 1 1970 00:09:57 GMT+0000),
    but couldn't set new date and time

  • Well, you can set time with the Web IDE - in fact that tutorial says:

    First step is to go into the Web IDE's settings (top right icon), then click Communications, then scroll down and make sure that Set Current Time is checked. Then the next time you send code to the Espruino board, the Web IDE will automatically set up its RTC.

    But also simply using the setTime command from the console works too (seconds since 1970 as a number) - it's what the Web IDE does behind the scenes.

    The main thing you need to get the time is getTime(), which returns seconds since 1970 (or by default in the original Espruino board, seconds since startup).

    Then you can initialise the Date class if you need to get more specific information about the time.

  • I knew about description from the tutorial, but till I get my espruino board I test IDE on my maple leaflabs. I know Web IDE set time itself when this option is marked but it set me wrong zone time,
    how can I set it?

  • Afraid you can't set a timezone at the moment - you'd just have to subtract or add that many seconds to the 'real' time.

  • ok, thanks Gordon

  • Ya... LAN-side C&C server that I use to send times to embedded devices has had the time zone and time set weirdly so when Espruino parses it's date, it gets the right time. Kind of annoying, because I have to turn off time sync, so the time drifts. It's now far enough behind reality that it's annoying me, and I'll need to nudge the time a bit this weekend.

  • ...'nudge' THE time... I like that! ;-) ...if this would be possible, I would put it more behind to enjoy the moments 'longer'...

  • How about a user option to set/detect time zone in the IDE and adjust the setTime setup accordingly to reflect local time instead of UTC?

  • Yes, that sounds like a good idea. I guess you'd still have problems with 'daylight saving time' but it'd be a great help for the majority of things.

    I added an 'issue' for it here: https://github.com/espruino/EspruinoTool­s/issues/17

  • Using the IDE's time zone (to set time to local instead of UTC) creates different behavior of being connected from disconnected from IDE.... except it is part of the saving...

  • If your espruino is connected to another device that knows the time,timezone and daylight saving, it could be easy (over Wifi or Xbee in my situation). In my setup i transfer seconds after EPOC (1970) minus/plus the differece to UTC to the espruino. I set the time with setTime on the espruino side then ignore the timezome at all. The time it self is correct ignoring the timezone (UTC) on the espruino at all.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Time settings in console.log ?

Posted by Avatar for bigplik @bigplik