1

A quick question on how i pass a timestamp from SQL trough PHP into JavaScript and then convert it into a unix timestamp.

The goal here is so retrieve a timestamp from my DB to which i add X hours and set is as endtime for my clock.

JavaScript

var deadline = new Date(Date.parse(new Date()) + 15 * 24 * 60 * 60 * 1000);
initializeClock('clockdiv', deadline);

PHP (time.php)

$sql = "SELECT max(time), time FROM user'";
foreach ($pdo->query($sql) as $row) {
echo date($row['time']);}

I get the time using

$('#sqltime').load('time.php');

But i am absolutely not sure how to

  • 1
    Possible duplicate?? Although it's not EXACTLY the same as it is but essentially your just asking to convert a mysql timestamp to a javascript date object: http://stackoverflow.com/questions/3075577/convert-mysql-datetime-stamp-into-javascripts-date-format – Paul Carlton Mar 08 '16 at 21:10

0 Answers0