Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
PHP: Countdown to a given date
<?php
$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