-
-
Save gboddin/803a9c1606cbdc53516e to your computer and use it in GitHub Desktop.
Some time routine ... I got bored :)
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_default_timezone_set('Europe/Brussels'); | |
$year = 0; | |
$month = 1; | |
$day = 0; | |
while(true) { | |
$day++; | |
$year = str_pad($year,4,"0",STR_PAD_LEFT); | |
$date = $year.'-'.$month.'-'.$day; | |
echo $date.' '.date('r',strtotime($date)).PHP_EOL; | |
switch($month) { | |
case 4: | |
case 6: | |
case 9: | |
case 11: | |
if($day == 30) { | |
$month++; | |
$day = 0; | |
} | |
break; | |
case 2: | |
if(($year % 4 != 0 && $day == 28)||($day == 29)) { | |
$month++; | |
$day = 0; | |
} | |
break; | |
case 12: | |
if($day == 31){ | |
$year++; | |
$month=1; | |
$day=0; | |
} | |
break; | |
default: | |
if($day == 31) { | |
$month++; | |
$day=0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment