• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Build Web Servers with ESP32 and ESP8266 – 3.3 – Web Server: Display Sensor Readings (Charts)

Q&A Forum › Category: ESP32 › Build Web Servers with ESP32 and ESP8266 – 3.3 – Web Server: Display Sensor Readings (Charts)
0 Vote Up Vote Down
Helmut Haeberli asked 5 years ago

Hello

  1. My time zone is not correct, where do I have to install something for Zurich?
  2. The first time you call it up, the time is displayed with decimal places, is there a suitable correction here?
6 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.

By default, JavaScript will use the browser’s time zone.
How many hours is it deviated from the actual time?

As for the time in the axis, we’re using the default timestamp: https://api.highcharts.com/highstock/xAxis.dateTimeLabelFormats

Can you try using:

dateTimeLabelFormats: { minute: '%H:%M' }

instead of the following in the JavaScript file:

dateTimeLabelFormats: { second: '%H:%M:%S' }

And see if it shows a more suitable time format?

Regards,

Sara

0 Vote Up Vote Down
Helmut Haeberli answered 5 years ago

Hello
I made this change but the result is the same. The X-axis time is still an hour behind. Also the timestamp goes back one hour. It is the same on the PC as on the smartphone.
My time zone setting is:
(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
I’m not sure why, but you probably need to adjust the time manually in the JavaScript code.
Here’s the code with UTC+01:00: https://gist.github.com/sarasantos/2b735d24b901e5ce36d0008dbe3c5505
Let me know if this code works for you.
 
Basically, create a new prototype addHours() to add how many hours you want to the UTC:

Date.prototype.addHours= function(h){
this.setHours(this.getHours()+h);
return this;
}

Then, simply use it on the Date() objects like this to add an hour:

var x = new Date().addHours(1).getTime();

Regards,
Sara

0 Vote Up Vote Down
Helmut Haeberli answered 5 years ago

Hello
Thanks for the tip, it works. My son has suggested another solution to me, which also works, see link:
https://api.highcharts.com/highcharts/time.getTimezoneOffset
https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/time/gettimezoneoffset/
Greetings
Helmut

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
Thanks for sharing that.
That’s a better solution as it uses the highcharts JS API.
Regards,
Sara

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

I’ll close this question.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.