0

I create a timestamp with strtotime php function. My question is how to "reverse" timestamp to year, month, date, ... seconds etc using javascript ?

prista
  • 361
  • 1
  • 5
  • 8
  • Reference: [PHP date functions](http://php.net/manual/en/ref.datetime.php) – Pekka Mar 23 '11 at 12:49
  • Reference: [PHP date functions (new, improved OOP way)](http://www.php.net/manual/en/class.datetime.php) – Pekka Mar 23 '11 at 12:50
  • possible duplicate of [How can I convert a php timestamp to the same format as new Date() in javaScript?](http://stackoverflow.com/questions/2415877/how-can-i-convert-a-php-timestamp-to-the-same-format-as-new-date-in-javascript) | also have a look at http://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript – Felix Kling Mar 23 '11 at 12:50

3 Answers3

1
var date = new Date(phptimestamp*1000);
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
//etc...
j0k
  • 22,600
  • 28
  • 79
  • 90
Zakaria
  • 14,892
  • 22
  • 84
  • 125
0
var date = new Date(seconds*1000);

where milliseconds is seconds since Jan 1970.

Robby Pond
  • 73,164
  • 16
  • 126
  • 119
0
var date = new Date(timestamp*1000);
sharpner
  • 3,857
  • 3
  • 19
  • 28