Time.month() strange result [SOLVED]

Hi Everyone,
The following give the correct results for the current hour/minute/second

hour = Time.hour();
minute = Time.minute();
second = Time.second();

However
month = Time.month();
returns 12 not 9

What am i doing wrong?

Thanks
Andy

Hello @andyg,

mine seems to be working fine. :smile:

Time now: Sun Sep  7 23:04:04 2014

Year: 2014
Month: 9
Day: 7
Weekday: 1
Hour: 23
Minute: 4
Second: 4
Is PM: 1
Is AM: 0

Can you try this code:


void setup(){
  Serial.begin(9600);
  while(!Serial.available()) Spark.process();
  Serial.print("Time now: ");
  Serial.print(Time.timeStr());
  Serial.print("\nYear: ");
  Serial.print(Time.year());
  Serial.print("\nMonth: ");
  Serial.print(Time.month());
  Serial.print("\nDay: ");
  Serial.print(Time.day());
  Serial.print("\nWeekday: ");
  Serial.print(Time.weekday());
  Serial.print("\nHour: ");
  Serial.print(Time.hour());
  Serial.print("\nMinute: ");
  Serial.print(Time.minute());
  Serial.print("\nSecond: ");
  Serial.print(Time.second());
  Serial.print("\nIs PM: ");
  Serial.print(Time.isPM());
  Serial.print("\nIs AM: ");
  Serial.print(Time.isAM());

}

Hi Kenneth,
My silly mistake = should have been ==
Thanks for your guidance…
Andy

2 Likes