-1

I have try to get date time from server to print on the Arduino console. Unfortunately,Month is not match from the current date time. It shows the last month (January) instead of February. By the way, date of month and year are correct. Here is a picture of code.

SetUp Wifi method:

enter image description here

Attribute:

enter link description here

GetDateTime:

enter image description here

Clifford
  • 88,407
  • 13
  • 85
  • 165
Mr.Kim
  • 186
  • 1
  • 10
  • 1
    Post your code as text in code mark-up - not _pictures of text_! Moreover _all_ your tags are irrelevant to this question. The one tag you need that is missing is [C]. – Clifford Feb 27 '18 at 12:50

1 Answers1

0

The range of tm_mon is from 0 to 11. Therefore you need to add "1" before representing. Here's the information of the structure from "man 3 localtime".

       struct tm {
           int tm_sec;    /* Seconds (0-60) */
           int tm_min;    /* Minutes (0-59) */
           int tm_hour;   /* Hours (0-23) */
           int tm_mday;   /* Day of the month (1-31) */
           int tm_mon;    /* Month (0-11) */
           int tm_year;   /* Year - 1900 */
           int tm_wday;   /* Day of the week (0-6, Sunday = 0) */
           int tm_yday;   /* Day in the year (0-365, 1 Jan = 0) */
           int tm_isdst;  /* Daylight saving time */
       };
Clifford
  • 88,407
  • 13
  • 85
  • 165
Kay
  • 144
  • 6