Skip to content

Instantly share code, notes, and snippets.

@davidcraig davidcraig/countdown.php
Last active Mar 31, 2017

What would you like to do?
PHP: Countdown to a given date
$date = ''; // Pass in your date variable here, eg $date = '2014-09-08'
$today = new DateTime();
$to = new DateTime($date);
$countdown = $today->diff($to);
// Seperate variables for days, months, years, etc.
$seconds = $countdown->s;
$days = $countdown->d;
$months = $countdown->m;
$years = $countdown->y;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.