note 33936 deleted from function.strtotime by sniper

From: Date: Tue, 21 Oct 2003 11:00:26 +0000
Subject: note 33936 deleted from function.strtotime by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58991@lists.php.net to get a copy of this message
Note Submitter: php_net@evgeny.ee ---- Two usefull functions, if you want to built your own calendar. ################ # Returns date of the Monday for given number of week(1..53) and year. # Output is in date-format. function get_monday($week, $year=""){ $first_date = strtotime("1 january ".($year ? $year : date("Y"))); if(date("D", $first_date)=="Mon") { $monday = $first_date; } else { $monday = strtotime("next Monday", $first_date)-604800; } $plus_week = "+".($week-1)." week"; return strtotime($plus_week, $monday); } ############### # analog to get_monday(), but returns Sunday: function get_sunday($week, $year=""){ return get_monday($week, $year)+604799; } ############### # Example: echo date("d.m.Y", get_monday(42, 2003)); // output is "13.10.2003"

« previous php.notes (#58991) next »