note 72298 added to function.strtotime

From: Date: Fri, 12 Jan 2007 01:34:04 +0000
Subject: note 72298 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-121571@lists.php.net to get a copy of this message
Here's a simpler function than the others I've seen in the comments to get the date range for a specific week using the ISO-8601 (monday through sunday week). Works with < php 5.1.0. function get_week_range($week, $year) { $first_monday = (8 - date("w", mktime(1,0,0,12,31,$year -1))) % 7; if ($first_monday == 0) $first_monday = 7; $fm_ts = mktime(1,0,0,1,$first_monday,$year); $monday = strtotime('+'.($week - 1).' week', $fm_ts); $sunday = strtotime('+6 days', $monday); $start = date("Y-m-d", $monday); $end = date("Y-m-d", $sunday); return array($start, $end); } ---- Server IP: 64.71.164.2 Probable Submitter: 208.179.142.254 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/72298 Del: integrated -- https://master.php.net/note/delete/72298/integrated Del: useless -- https://master.php.net/note/delete/72298/useless Del: bad code -- https://master.php.net/note/delete/72298/bad+code Del: spam -- https://master.php.net/note/delete/72298/spam Del: non-english -- https://master.php.net/note/delete/72298/non-english Del: in docs -- https://master.php.net/note/delete/72298/in+docs Del: other reasons-- https://master.php.net/note/delete/72298 Reject -- https://master.php.net/note/reject/72298 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#121571) next »