note 106363 added to function.date

From: Date: Mon, 31 Oct 2011 10:51:33 +0000
Subject: note 106363 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-184242@lists.php.net to get a copy of this message
How to get the week starting date by giving a week number and the year. Monday first day in week function WeekStartDate($week,$year,$format="d-m-Y") { date_default_timezone_set('Europe/Paris'); $firstDayInYear=date("N",mktime(0,0,0,1,1,$year)); if ($firstDayInYear<5) $shift=-($firstDayInYear-1)*86400; else $shift=(8-$firstDayInYear)*86400; if ($week>1) $weekInSeconds=($week-1)*604800; else $weekInSeconds=0; $timestamp=mktime(0,0,0,1,1,$year)+$weekInSeconds+$shift; return date($format,$timestamp); } echo WeekStartDate(44,2011); //result: 31-10-2011 ---- Server IP: 69.147.83.197 Probable Submitter: 80.199.142.174 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/106363 Del: integrated -- https://master.php.net/note/delete/106363/integrated Del: useless -- https://master.php.net/note/delete/106363/useless Del: bad code -- https://master.php.net/note/delete/106363/bad+code Del: spam -- https://master.php.net/note/delete/106363/spam Del: non-english -- https://master.php.net/note/delete/106363/non-english Del: in docs -- https://master.php.net/note/delete/106363/in+docs Del: other reasons-- https://master.php.net/note/delete/106363 Reject -- https://master.php.net/note/reject/106363 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184242) next »