note 72298 deleted from function.strtotime by derick

From: Date: Sun, 15 Jul 2007 12:37:36 +0000
Subject: note 72298 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-128550@lists.php.net to get a copy of this message
Note Submitter: eric at narcopia dot com ---- 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); }

« previous php.notes (#128550) next »