Displaying daily account in php

I would like to show the number of days missing on a specific date. In other words, I want to show something like:

X days for a big event

using PHP and server time.

+1


a source to share


2 answers


<?php

    $event_date = '2010-01-01 00:00:00';
    $event_time = strtotime($event_date);
    $diff = $event_time - time();
    echo floor($diff/(24*60*60)).' days to go for the great event';

?>

      



Note . I completely reject any timezone considerations, so be sure to read the timezone questions related to using PHP functions datetime

.

+9


a source


Jakemcgraw's answer would get my vote if I was 15 rep. :)



You might want to use mktime () instead of strtotime ().

+3


a source







All Articles