Last active
March 31, 2017 09:04
-
-
Save davidcraig/dc057571b07983a5d2d833f9d09cdbfc to your computer and use it in GitHub Desktop.
PHP: Countdown to a given date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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