Advertisement
comniemeer

Untitled

Jan 3rd, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.06 KB | None | 0 0
  1. <?php
  2. define("TIME_ZONE", 1);
  3.  
  4. function isLeapYear($year) {
  5.     return $year % 400 == 0 || ($year % 4 == 0 && $year % 100 != 0);
  6. }
  7.  
  8. function mktimeEx($hour, $minute, $second, $day, $month, $year) {
  9.     $days_of_month = [
  10.             0   * 86400, 31  * 86400, 59  * 86400,
  11.             90  * 86400, 120 * 86400, 151 * 86400,
  12.             181 * 86400, 212 * 86400, 243 * 86400,
  13.             273 * 86400, 304 * 86400, 334 * 86400
  14.         ];
  15.    
  16.     $lMonth;
  17.     $lYear;
  18.     $lMonthS;
  19.     $lYearS;
  20.    
  21.     if ($year != $lYear) {
  22.         $year -= 1970;
  23.         // Subtract the UNIX epoch.
  24.         // Get full years.
  25.         $lYearS = $year * 31536000;
  26.         // Add leap years.
  27.         $lYearS += 86400 * ($year / 4);
  28.         // Remove false leap years.
  29.         // Adjust for the odd start point.
  30.         $year += 70;
  31.         // Remove all hundreds.
  32.         $lYearS -= ($year / 100) * 86400;
  33.         // Add the 400s back.
  34.         $year += 300;
  35.         $lYearS += ($year / 400) * 86400;
  36.         $year += 1600; // 1970 - 370
  37.         $lYear = $year;
  38.     }
  39.    
  40.     // Adjust to 0 start.
  41.     if ($month != $lMonth) {
  42.         $month--;
  43.         $lMonthS = $days_of_month[$month];
  44.         if ((isLeapYear($year) && $month >= 2) || isLeapYear($year - 1)) {
  45.             // Add an extra day.
  46.             $lMonthS += 86400;
  47.         }
  48.         $lMonth = $month + 1;
  49.     }
  50.    
  51.     $day = ($day - 1) * 86400;
  52.     $hour = ($hour - (0 + TIME_ZONE)) * 3600;
  53.     $minute = $minute * 60;
  54.    
  55.     return $lYearS + $lMonthS + $day + $hour + $minute + $second;
  56. }
  57.  
  58. for ($year = 2000; $year <= 2030; $year++) {
  59.     for ($month = 1; $month <= 12; $month++) {
  60.         for ($day = 1; $day <= 31; $day++) {
  61.             if ($month == 2 && $day > 28) {
  62.                 continue;
  63.             } else if ($day > 30) {
  64.                 if ($month == 4 || $month == 6 || $month == 9 || $month == 11) {
  65.                     continue;
  66.                 }
  67.             }
  68.            
  69.             $mktimeEx = mktimeEx(0, 0, 0, $day, $month, $year);
  70.             $mktime = mktime(0, 0, 0, $month, $day, $year);
  71.            
  72.             echo $day . "." . $month . "." . $year . ": " . $mktime . "-" . $mktimeEx . "-" . ($mktime == $mktimeEx ? "+" : "x") . "<br>";
  73.            
  74.             /*if ($mktimeEx != $mktime) {
  75.                 echo $day . "." . $month . "." . $year . ": " . $mktime . "-" . $mktimeEx . " " . ($mktime == $mktimeEx ? "+" : "x") . "<br>";
  76.             }*/
  77.         }
  78.     }
  79. }
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement