1

I am trying to run a counter from the time user is entered into database

I got this fiddle

http://jsfiddle.net/brkp1sa2/

which starts timer from 08/24/2012 while i need to start it from user date which i enter into database as timestamp at the time of signup

How I can do it as I fetch val from database like

<?php $timd = $db->fetchVal("select ts from users where id  = ?", $id); 
if (!empty($timd)) {
    $timdl = $timd->ts;
 }

Not know php pr jquery much so a code example answer can help me better

How to use this value into jquery so time start from given time stamp

O. Jones
  • 103,626
  • 17
  • 118
  • 172
john
  • 107
  • 9

1 Answers1

0

Javascript timestamps are Javascript numbers representing Unix time in milliseconds. MySQL uses its UNIX_TIMESTAMP() function to generate Unix timestamps (in seconds) from various kinds of date / time datatypes.

So, the query

    select UNIX_TIMESTAMP(ts) * 1000.0 AS ts from users where id  = ?

will generate a Javascript timestamp value.

Now, Javascript timestamps and Unix timestamps are, by design at least, in the UTC time zone. Depending on how your table's ts values were stored, your results may come out in local time.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • Issue is not ts basic issue is how to use this string into jquery as `fetchVal("select ts from users where id = ?", $id); ` outputs `$timd` as 2016-12-24 03:04:59 and if i succeed to put into jquery value here `var timespan = countdown(new Date("2016-12-24 03:04:59"` then jquery will start timer from that specific date and time – john Jan 16 '17 at 13:17