note 81808 added to function.strftime

From: Date: Fri, 14 Mar 2008 09:25:35 +0000
Subject: note 81808 added to function.strftime
Groups: php.notes 
Request: Send a blank email to php-notes+get-137049@lists.php.net to get a copy of this message
Fetch a timestamp or datetime of a given week can be accomplished very easy... /** * Get the start of a given week (in this case monday is first day = W) * * @param integer $iWeekNumber * @param integer $iYear * @param string $sFormat * @return mixed Datetime or UNIX time depending on format */ function getDatetimeWeekStart( $iWeekNumber, $iYear, $sFormat = 'd\.m\.Y' ) { $iWeekNumber = sprintf("%02s", $iWeekNumber); $iTime = strtotime($iYear.'W'.$iWeekNumber); return date($sFormat, $iTime); } Example this week: print getDatetimeWeekStart(date('W')); Example week 10 in 2006: print getDatetimeWeekStart(10, 2006); Example week 52 in 2009 in unixtime: print getDatetimeWeekStart(52, 2009, 'U'); Best regards Jesper HorsMark ---- Server IP: 87.54.44.10 Probable Submitter: 83.95.109.131 ---- Manual Page -- http://www.php.net/manual/en/function.strftime.php Edit -- https://master.php.net/note/edit/81808 Del: integrated -- https://master.php.net/note/delete/81808/integrated Del: useless -- https://master.php.net/note/delete/81808/useless Del: bad code -- https://master.php.net/note/delete/81808/bad+code Del: spam -- https://master.php.net/note/delete/81808/spam Del: non-english -- https://master.php.net/note/delete/81808/non-english Del: in docs -- https://master.php.net/note/delete/81808/in+docs Del: other reasons-- https://master.php.net/note/delete/81808 Reject -- https://master.php.net/note/reject/81808 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137049) next »