Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Time on clock face and clock API in app differ by two hours

ANSWERED

I am playing with a Sense, and wrote a little app, just displaying the time, heartbeat, steps  acceleration.

 

It works, but the time displayed in the app is two hours behind.

The original clockface gives the right time.

 

Moderator Edit: Formatting.

 

Anyone knows why? My first thought was TIMEZONE but apparently it is not used in the device.

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

It is probably timezone (especially if you're in a -2 or +2 zone).

If you use the Date object provided to the ontick listener, time zone will have been taken into account.

If you get a Date object from anywhere else, it may not be adjusted for time zone. What you get out of it depends on how you use it. Details here.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
3 REPLIES 3

It is probably timezone (especially if you're in a -2 or +2 zone).

If you use the Date object provided to the ontick listener, time zone will have been taken into account.

If you get a Date object from anywhere else, it may not be adjusted for time zone. What you get out of it depends on how you use it. Details here.

Peter McLennan
Gondwana Software
Best Answer

Thx for ref! Yes, I am in NL, two hours from the UK 🙂

Best Answer
0 Votes
Well both

clock.addEventListener("tick", (evt) => {
clockDisplay.text = evt.date.toLocaleTimeString().slice(0, -4);
});

and

clock.addEventListener("tick", (evt) => {
clockDisplay.text = evt.date.toTimeString().slice(0, -4);
});

give a minus 2 hours difference from the official clock face, which is GMT,
here is GMT+2
Best Answer
0 Votes