I'm having an issue getting the correct Timezone to display in charts that i'm embedding on other webpages. The timezone parameter doesn't seem to be changing what Thingspeak is displaying on the X axis. Here is the very simple chart I'm trying to display.
The timezone in my account is set to Pacific Standard Time (I'm in California), but my channel and hardware is in India. For the future, I will be having multiple channels probably with different time zones. The API says this should work. https://thingspeak.com/docs/charts
I tried the offset parameter to see if it had something to do with my settings, and that is also displaying my current PST time.
I also tried changing my account settings to a different timezone (Asia/Kolkata) and that did not remedy the issue.
As you mentioned, you can use the timezone parameter or the offset parameter to request for data from a field in a specific time zone. For e.g:
However, thingspeak high-charts are designed to use the browser timezone (thereby the OS timezone) always. Therefore, even when the feed parameter for setting timezone is specified, the high-chart will always default back to using the browser timezone. Note that, changing the OS clock's timezone should lead to thingspeak high-chart display to change the timezone used for x-axis. But, changing your account setting will not affect it.
To enable charts to be displayed with fixed timezones, create a MATLAB Visualization App, read data from your channel, change the timezone and create a plot. For example:
[data, time] = thingSpeakRead(52499, 'Fields', 1, 'NumPoints', 100);
time.TimeZone = 'Asia/Kolkata';
xlabel('Time in Kolkata timezone');
title('Data displayed with Shifted timezone');
You can then embed the MATLAB plot into other webpages.
For more information on the datetime function, following this link:
Thanks Adarsh. I had a feeling I would have to use MatLab to do this and you have verified my thoughts.
Does that mean that the timezone parameter (in ThingSpeak charts) is basically useless? If it always defaults to the browser timezone, then I don't see a reason for stating it as a parameter in the API under the charts section.
You are right. The timezone parameter is controlling the display of timestamps for the feed data only, i.e.,
It does not have any effect on the x-axis display in the charts though. We will add to the documentation to explain this behavior. Thanks for bringing this to our attention.
Most Users Ever Online: 114
Currently Browsing this Page:
Guest Posters: 1
Administrators: Hans, lee