Matlab Thingspeakwrite data appears 1 day off | MATLAB | Forum


Please consider registering


— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Matlab Thingspeakwrite data appears 1 day off

Forum Posts: 70
sp_UserOfflineSmall Offline
January 25, 2018 - 3:09 pm
sp_Permalink sp_Print sp_EditHistory

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?


Forum Posts: 70
sp_UserOfflineSmall Offline
January 25, 2018 - 6:40 pm
sp_Permalink sp_Print

I see in the documentation that:  "the Timestamp provided is interpreted in local timezone."

How do I get thingspeak to take my timestamp data in UTC, or how do I convert it to local time, accounting for daylight savings time?


Forum Posts: 70
sp_UserOfflineSmall Offline
January 25, 2018 - 7:07 pm
sp_Permalink sp_Print sp_EditHistory

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?


Forum Posts: 62
sp_UserOfflineSmall Offline
January 26, 2018 - 2:16 pm
sp_Permalink sp_Print

Hi turgo,

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.




Forum Posts: 70
sp_UserOfflineSmall Offline
January 26, 2018 - 5:13 pm
sp_Permalink sp_Print

Thanks Adarsh.


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.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
35 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:







Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565


Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee