How to get timezone with Espruino

Posted on
  • Does anyone know how to get the current timezone e.g. current date and time with Espruino... I have had a look at the reference and there is only a getTime(); function which gets you the time in seconds since the device has been booted up... As Espruino doesn't have the JavaScript Date function does anyone know how we can get the current Date and Time?

    p.s. I am new to this

  • The Espruino doesn't know what the current date and time is until you tell it, let alone the time zone.

    It also doesn't keep time well enough to use as a clock without an external crystal - see

    I know someone else here was working on a Date module that might be useful.

  • As @DrAzzy says, Martin has actually just made a module that implements the date object - so just what you're after. He's submitted it so it'll go live on the website early next week.

    It's probably best to wait until that's up, as it comes with some example code too...

  • How exactly would you 'tell it' the date and time? That is what I am getting at

  • Maybe you need a RTC Chip like this:

  • They have example code on the clock page I linked to above, under the software section - of course, that's without the new date module... I haven't seen the date module, so I don't know how that would be different.

  • @Sacha - Espruino has an RTC inside it already - so no need for that. All you need is some code that'll convert the time in seconds to a proper date + time. I'll try and get that uploaded today.

  • Oh. Thanks.


  • Also check this -¬≠epoch.php

    If you have ethernet, you can use this to get the time without requiring NTP

  • the Date / Clock modules are very useful - and I am sorry to bump an older thread... but... is it me or there is no getSeconds exported on Date ?

  • Argh. Thanks for letting me know - it was a mistake in the code where getSeconds got exported over the top of getMinutes. It'll be fixed in 1v66, but it should be relatively easy to fake with:

    Date.prototype.getSeconds = function() {
      return (0|(;
  • Thanks for fixing :)

  • Sure, I just wanted to post this so you know as well :)

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

How to get timezone with Espruino

Posted by Avatar for user6933 @user6933