Skip to content

Instantly share code, notes, and snippets.

@gboddin
Created December 24, 2014 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gboddin/803a9c1606cbdc53516e to your computer and use it in GitHub Desktop.
Save gboddin/803a9c1606cbdc53516e to your computer and use it in GitHub Desktop.
Some time routine ... I got bored :)
<?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