mardi 2 avril 2019

Last day since accident webpage is showing 1970 januar 1 on all the samsung smart TV Internet app

I have created a simple webpage with some html and javascript.

It has a simple function:To count days since given date. On all the PC-s it is working fine and calculating the date nicely, but on the newly purchased Samsung Smart TV-s it is showing for current time "1970-jan-01" And counting all wrong.

Additional info (may help). First when I unpacked the TV and started the webpage it showed the right time and calculated the correct date, but after I turned it off and on again it messed up the calculation

What am I missing?

It is hosted on a local linux machine, and as I mentioned It is working fine on all the personal computers, tablets, mobiles.

I am not an experienced coder, but i like to tinker around with simple stuff, but I cannot really grab onto the problem.

const second = 1000,
      minute = second * 60,
      hour = minute * 60,
      day = hour * 24;


let countUp = new Date('December 05, 2018 17:40:00').getTime(),
    x = setInterval(function() {

      let now = new Date().getTime(),
          distance = now - countUp;

        document.getElementById('days').innerText = Math.floor(distance / (day)),
        document.getElementById('hours').innerText = Math.floor((distance % (day)) / (hour)),
        document.getElementById('minutes').innerText = Math.floor((distance % (hour)) / (minute)),
        document.getElementById('seconds').innerText = Math.floor((distance % (minute)) / (second));


    }, second)

I expect it to be (if we take today's date 2019.04.03) to show: 118 DAY 13 HOUR 11 MINUTE 5 SECONDS

but on the Smart TV' it is showing like -1000 days and so on

Thank you very much for the help.




Aucun commentaire:

Enregistrer un commentaire