Local time change
Closed this issue · 1 comments
mawebdev commented
Bug Report or Feature Request (mark with an x
)
[x] Bug report -> please search issues before submitting
[ ] Feature request
[ ] Documentation issue or request
Current behavior
I set the leftTime to a specific time, e.g. 120 seconds.
When I change the time of my local machine, it also changes the counter.
Expected behavior
- I get a server timestamp and I want to start a counter based on a time difference between two dates.
- A local date/time change shouldn't affect the countdown (because the date is a server timestamp, therefore it has nothing to do with his local datetime).
Environment
Angular version: 10.0.14
ngx-countdown version: 11.0.0
Browser:
- all devices (Ionic 5)
Others:
cipchk commented
Sorry ngx-countdown does need a local time to maintain the countdown frequency. In fact, what you get from the server is a timestamp, which you can convert into seconds based on local time, for example:
const timestamp = +new Date() + (1000 * 10); // mock from serve
const seconds = (timestamp - +new Date()) / 1000;
const config: CountdownConfig = { leftTime: seconds };