Date.month() is one month behind?

Here’s the code:

local now = date();
query.scanTimestamp <- format("%i-%i-%iT%i:%i:%i.000Z", now.year, now.month, now.day, now.hour, now.min, now.sec);
server.log("now: " + query.scanTimestamp);

And the answer is:

2014-12-23 16:55:32 UTC-8 [Agent] now: 2014-11-24T0:55:32.000Z

Note November and not December.

It’s got to be something dumb I’m doing … it usually is …

Gerry.

it is zero based

0-11; January = 0

For some reason only day of the month is not zero-based.

The value for date.month is zero based, not one based. This allows the value to be used directly as the index into an array of month names. This is mentioned in http://electricimp.com/docs/squirrel/system/date/.

dowp RTFM

Thx

g