Countup timer

I have

date( 'm/d/y g:i A', strtotime($row['created_date']))

which produces
image
which is a TIMESTAMP in a mysql table.
Is there a way create a timer on it ( so you can see the days, hours, minutes, and seconds since then?

I think I need to convert the date like
image

strtotime of your created_date returns a number of seconds.
time by itself returns the number of seconds of the current time.

The difference between the two is your ‘since then’.

alternatively, DateTime::diff.

I’m trying to format my date, using the date() to make it look better and am confused

$time = strtotime($row['created_date']);
$c_date = date("m/d/y g:i A", $time);
...
...
$formatted_date = $row['created_date '] =  date('M d, Y H:i:s');
echo $c_date." => ".$formatted_date;

produces

02/05/20 10:09 AM => Feb 06, 2020 18:09:02
Shouldn’t the dates be the same, just formatted differently?

do you notice something missing from your second line? What will the consequence of the missing term be?

didnt incclude the second parameter

$formatted_date = date('M d, Y H:i:s',$time1);
1 Like

If you forget the second parameter, date assumes you mean time(), AKA “Now. Right now. The exact second that this command was run.”, hence, the date being different.

1 Like