Difference between local time and "created_at
11 views (last 30 days)
Show older comments
Hello
The time returned by "created_at" does not correspond to the local time
e.g. 18:54:33.401 -> Message:{"channel_id":2499901, "created_at": "2024-08-21T16:54:31Z"....}
although my profile is correctly filled in, the time indicated on the plot is correct
Should I add the term: ?timezone = Europe%2FParis
if where please I do not have a field in "channel setting" to add it
Thank you in advance.
0 Comments
Answers (2)
Walter Roberson
on 21 Aug 2024
"2024-08-21T16:54:31Z"
The Z at the end of the timestamp specifically means "Zulu" time, which is UTC.
It would be expected that times in that format would be converted to be in timezone UTC. To plot them in local time, you would need to change the TimeZone property of the data.
Star Strider
on 21 Aug 2024
To illustratte —
TZ = timezones("Europe");
disp(TZ)
MessageTime = datetime("2024-08-21T16:54:31Z", 'InputFormat','yyyy-MM-dd''T''HH:mm:ssZ', 'TimeZone','Europe/Paris')
.
4 Comments
Star Strider
on 22 Aug 2024
I have no experience with ThingSpeak.
One option —
dts = extractBetween('{"channel_id":2499901,"created_at":"2024-08-22T11:48:14Z","entry_id":34325,"field1":"34.10","field2":"34.40","field3":"69","field4":"27.81","field5":null,"field6":null,"field7":null,"field8":null,"latitude":null,"longitude":null,"elevation":null,"status":null}', '"created_at":',',')
MessageTime = datetime(dts{:}, 'InputFormat','"yyyy-MM-dd''T''HH:mm:ssZ"', 'TimeZone','Europe/Paris')
I am not certain how to extract that particular information (the Message cell array to use in the extractBetween call) from whatever ThingSpeak returns, however if you can do that, this approach should work.
.
See Also
Categories
Find more on Read Data from Channel in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!