nudo01 Posted November 2, 2010 Share Posted November 2, 2010 So, my problem is that I need to edit my Xmas calculator to understand when this year's Xmas is over, it will automatically jump to the next one (2011-12-25). I have no idea how to do this (noob to php...) Thanks in advance. Here's my code: <?php $time=time(); $xmas=strtotime("2010-12-25 00:00:00"); $diff = $xmas - $time; $days=intval($diff/86400); $left=$diff%86400; $hs=intval($left/3600); $left=$left%3600; $mins=intval($left/60); $secs=$left%60; echo "<font size=12 face=corbel> Xmas is after:<br> <strong>$days days</strong><br> <strong>$hs hours</strong><br> <strong>$mins mins $secs secs</strong>! </font>"; ?> Link to comment https://forums.phpfreaks.com/topic/217554-strtotime-how-to/ Share on other sites More sharing options...
Airzooka Posted November 2, 2010 Share Posted November 2, 2010 I didn't check your breakdown of months/days/minutes/seconds, but you can use this snippet to find the year of the next Christmas: (Works from 2010 and onward) $now = time(); $year = 2010; while (strtotime($year . '-12-25') < $now) { $year++; } // $year is now the year of the next christmas Link to comment https://forums.phpfreaks.com/topic/217554-strtotime-how-to/#findComment-1129389 Share on other sites More sharing options...
nudo01 Posted November 2, 2010 Author Share Posted November 2, 2010 Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/217554-strtotime-how-to/#findComment-1129406 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.