You can chat about native SDK questions and issues here.

User avatar
By Agentsmithers
#82089
Code: Select allip_addr_t *addr = (ip_addr_t *)os_zalloc(sizeof(ip_addr_t));
      sntp_setservername(0, "us.pool.ntp.org"); // set server 0 by domain name
      sntp_setservername(1, "ntp.sjtu.edu.cn"); // set server 1 by domain name
      ipaddr_aton("210.72.145.44", addr);
      sntp_setserver(2, addr); // set server 2 by IP address
      sntp_set_timezone(+7); //Commenting this out uses UTC, We are PST +7
      sntp_init();
      os_free(addr);


When I call sntp_get_current_timestamp() it returns back that the time is now May 1st at 9:28:25 2019 but when submitting my value to my PHP script I use FROM_UNIXTIME() function to convert the big integer value passed to submit to my database it enters the value 2019-05-01 02:28:25 into the database, but when I view the data with Grafana all my timestamps are directly correct with the time taken and my system clock. Any MySQL and time guru's out there that can give me a tip on properly storing the UTC time. I don't want to have to deal with LEAPs and Day Light Savings time so I think the Universal TC is the way to go as the Unix timestamp considers those things..

Computer Clock reflects April 30 19:28:25
ESP reflects May 01 09:28:25
PHPMyadmin/MYSQL reads 2019-05-01 02:28:25 - Stores in SQL as a TIMESTAMP, SELECT @@system_time_zone; returns MST
Grafana Reads all times correct to reflect samples taken at the time of 19:28:25 on April 30 as they should

How should the ESP and PHP reflect the true data? Should the entries in my database READ as if I'm reading my local timezone or should there be an offset so it reflects the correct universal time but the DBadmin will see the times reflect in the future (As expected)

Thanks for any guidance!!
You do not have the required permissions to view the files attached to this post.
Last edited by Agentsmithers on Wed May 01, 2019 10:35 pm, edited 2 times in total.
User avatar
By Bonzo
#82101 I had a problem with a date/time as it was 1 hour out due to summer time. Although my host is in the UK I still had to add date_default_timezone_set('Europe/London'); once at the top of the php page which corrected the time.
I then used this to format my date to be saved in the database: $date = date("Y-m-d",strtotime());

If your host is in another time zone this should correct it. To be honist I was a bit unsure about the problem in your post.