1

Hello i need to get this date value from php 1328569380 and convert it to javascript date. By the way how is this date "1328569380" type of form called ?

themhz
  • 8,335
  • 21
  • 84
  • 109

3 Answers3

10

The numeric date time your are referring to is called a timestamp. It is the number of seconds elapsed since january 1st of 1970 if i'm not wrong.

To send a date to javascript, just print it out using the timestamp x 1000 since it also accepts millisecond initialization format:

mydate = new Date(<?php echo $mytimestamp*1000; ?>);

Good luck

Mathieu Dumoulin
  • 12,126
  • 7
  • 43
  • 71
2

This is a Unix epoch timestamp. See the following thread for the how-to:

Convert a Unix timestamp to time in JavaScript

Community
  • 1
  • 1
Wes Crow
  • 2,971
  • 20
  • 24
1

Your value is the number of seconds that has passed since 1970-01-01 00:00:00, called the Unix epoch.

JavaScript counts the number of milliseconds instead, thus you have to multiply your timestamp with 1000 prior to using it to create a JavaScript date-object.

var phptimestamp = 1328569380;
var date = new Date(phptimestamp * 1000);
Christofer Eliasson
  • 32,939
  • 7
  • 74
  • 103