Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a unix timestamp countdown

I want to have a countdown to a unix timestamp: Where it counts down in seconds

Like this:

Expires in: 1d 10h 52m 25s

Heres an example timestamp: 1303725600

How could I do that?

like image 573
AndrewFerrara Avatar asked Apr 23 '11 23:04

AndrewFerrara


1 Answers

I think this would work...

$tDiff = 1303725600 - time();

$days = floor($tDiff / 86400);
$hours = ($tDiff / 3600) % 24;
$mins = ($tDiff / 60) % 60;
$secs = ($tDiff) % 60;
like image 70
James C Avatar answered Sep 23 '22 14:09

James C