I've having a weird issue on Puck with datetime.
I have "Send time to Espruino" set in the IDE.
If I do new Date(Date.now()).getHours() or new Date(Date.now()).getMinutes(), I get the right thing.
But new Date(Date.now()).getMonth() is returning 5 and new Date(Date.now()).getDay() is also returning 5. (That's for today). Yesterday it was 4 for getDay().
This is on 1v92 using standalone Windows IDE espruino_ide_win64_0v65.9
Any idea where this offset could be coming from?
Odd - what happens if you do (new Date()).toString()
Hmm, it's right:
"Fri Jun 9 2017 10:36:48 GMT+0000"
Strange. Maybe it's the way you do new Date(Date.now()) rather than just new Date() - I guess it could also be a bracketing thing.
Also, the values returned for getMonth/etc start from 0 - not 1. So you'd expect this month - the 6th month - to return 5. The fact the days are wrong is very strange though
Good to know re month, thanks.
Ahhhhhhhhhhhh, getDay() is Day of Week!
User error completely :-) Ignore me ;-)
No problem - glad it's sorted ;)
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem