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
  • 311
  • 1
  • 4
  • 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

4 Answers4

1

This question has been asked and answered a few times before. Take a look here for a collection of good solutions.

Community
  • 1
  • 1
Dave Child
  • 7,068
  • 2
  • 23
  • 37
1
var date = new Date(phptimestamp*1000);
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
//etc...
j0k
  • 22,303
  • 28
  • 77
  • 86
Zakaria
  • 14,664
  • 22
  • 83
  • 123
0
var date = new Date(seconds*1000);

where milliseconds is seconds since Jan 1970.

Robby Pond
  • 72,024
  • 16
  • 123
  • 118
0
var date = new Date(timestamp*1000);
sharpner
  • 3,719
  • 3
  • 18
  • 27