note 38920 deleted from function.mktime by bjori

From: Date: Thu, 01 Jun 2006 18:40:11 +0000
Subject: note 38920 deleted from function.mktime by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-112813@lists.php.net to get a copy of this message
Note Submitter: rickenmeer at hotmail dot com ---- <?PHP function &mktime ($hour = false, $minute = false, $second = false, $month = false, $date = false, $year = false) { // For centuries, the Egyptians used a (12 * 30 + 5)-day calendar // The Greek began using leap-years in around 400 BC // Ceasar adjusted the Roman calendar to start with Januari rather than March // All knowledge was passed on by the Arabians, who showed an error in leaping // In 1232 Sacrobosco (Eng.) calculated the error at 1 day per 288 years // In 1582, Pope Gregory XIII removed 10 days (Oct 15-24) to partially undo the // error, and he instituted the 400-year-exception in the 100-year-exception, // (notice 400 rather than 288 years) to undo the rest of the error // From about 2044, spring will again coincide with the tropic of Cancer // Around 4100, the calendar will need some adjusting again if ($hour === false) $hour = Date ("G"); if ($minute === false) $minute = Date ("i"); if ($second === false) $second = Date ("s"); if ($month === false) $month = Date ("n"); if ($date === false) $date = Date ("j"); if ($year === false) $year = Date ("Y"); if ($year >= 1970) return mktime ($hour, $minute, $second, $month, $date, $year); // date before 1-1-1970 (Win32 Fix) $m_days = Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if ($year % 4 == 0 && ($year % 100 > 0 || $year % 400 == 0)) { $m_days[1] = 29; // non leap-years can be: 1700, 1800, 1900, 2100, etc. } // go backward (-), based on $year $d_year = 1970 - $year; $days = 0 - $d_year * 365; $days -= floor ($d_year / 4); // compensate for leap-years $days += floor (($d_year - 70) / 100); // compensate for non-leap-years $days -= floor (($d_year - 370) / 400); // compensate again for giant leap-years // go forward (+), based on $month and $date for ($i = 1; $i < $month; $i++) { $days += $m_days [$i - 1]; } $days += $date - 1; // go forward (+) based on $hour, $minute and $second $stamp = $days * 86400; $stamp += $hour * 3600; $stamp += $minute * 60; $stamp += $second; return $stamp; } ?>

« previous php.notes (#112813) next »