-
• #2
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 http://www.espruino.com/Clocks
I know someone else here was working on a Date module that might be useful.
-
• #4
How exactly would you 'tell it' the date and time? That is what I am getting at
-
• #5
Maybe you need a RTC Chip like this:
-
• #6
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.
-
• #8
Oh. Thanks.
Sacha
-
• #9
Also check this - currentmillis.com/api/millis-since-unix-epoch.php
If you have ethernet, you can use this to get the time without requiring NTP
-
• #10
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 ?
-
• #11
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|(this.ms/1000))%60; }
-
• #12
Thanks for fixing :)
-
• #13
Sure, I just wanted to post this so you know as well :)
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