2

When I do this in php

echo date("Y/m/d",786668400);

I get 1994/12/06

but when I do this in javascript:

console.log(new Date(786668400*1000).getDate() + "." + 
           (new Date(786668400*1000).getMonth() + 1) + "." + 
            new Date(786668400*1000).getFullYear());

I get 5.12.1994

The date is wrong, it should be 6.12.1994

what am I doing wrong here?

    console.log(new Date(786668400 * 1000).getDate() + "." +
      (new Date(786668400 * 1000).getMonth() + 1) + "." +
      new Date(786668400 * 1000).getFullYear());
cfreear
  • 1,855
  • 2
  • 19
  • 25

1 Answers1

0

Your unix timestamp gives you the wrong date, because in UTC time it's 05.12.1994 23:00:00. In my local timezone, it's 06.12.1994 00:00:00

Try changing your timezone.

Matt Backslash
  • 764
  • 1
  • 8
  • 20