I'm using thingspeakwrite to upload Nov 2013 data to a new channel. I downloaded data from a channel dated: 22-Nov-2013 00:00:00 UTC
The last data point I processed and wrote is dated 22-Nov-2013 00:00:00.
When I view the data on the graph in the private view on my channel, the last date is: 22-Nov-2013 00:00:00 GMT - 800
When I download the newly written channel, the last date is: 2013-11-22 08:00:00 UTC
My data appears to have been shifted ahead 8 hours on the thingspeakwrite step.
Is there an error in the way thingspeak is handling these dates, or is there some nuance that I don't understand?
This timestamp business is a confusing topic.
1. For example, when I use thingspeakread in matlab, are the start and end dates in UTC or local time? The documentation doesn't say.
2. Is thingspeakread returning UTC or local time in a timetable?
3. Are the datetime values shown in Matlab UTC or local time.
4. If I set a local timezone(d.TimeZone = 'America/New_York'), does it affect the timetable I send to thingspeakwrite, or just the display values in the matlab output pane?
datetime('now') function in MATLAB by default displays the local timezone defined in MATLAB. If you set the time, i.e., evaluate code like
dt = datetime('1-Jan-2018'),
then the datetime value is assigned to dt (without a timezone). you can assign a timezone to this variable by setting the property:
dt.TimeZone = 'America/New_York'
dt.TimeZone = 'local'
Refer to this link for further information:
When you use ThingSpeakRead in MATLAB, the returned timestamps are always in local time by default. This is the case whether you return the data in an array, table, and timetable, i.e., for each of the cases below, timestamps will be in your local timezone:
[data, time] = thingSpeakRead(12397, 'NumPoints', 10);
dataT = thingSpeakRead(12397, 'NumPoints', 10, 'OutputFormat', 'table');
dataTT = thingSpeakRead(12397, 'NumPoints', 10, 'OutputFormat', 'timetable');
If the timestamps provided to thingSpeakWrite do not have their TimeZone property set, then thingSpeakWrite assumes local timezone (as defined by MATLAB). Else if the timestamps provided to thingSpeakWrite have their TimeZone property set, then thingSpeakWrite will use the specified TimeZone.
Upon examination of the flow of dates in and out of matlab and thingspeak, I think that there is no problem with the new recorded data:
1. thingspeakread Start and end dates are in local time.
2. Results are returned from thingspeakread to matlab in local time.
3. Datetime values displayed in Matlab are in local time
4. Didn't mess with d.Timezone
5. thingspeakwrite converts local times to UTC and writes UTC to the channel feed.
Most Users Ever Online: 114
Currently Browsing this Page:
Guest Posters: 1
Administrators: Hans, lee