note 36113 added to function.date

From: Date: Fri, 26 Sep 2003 04:32:33 +0000
Subject: note 36113 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-57149@lists.php.net to get a copy of this message
# takes a date and returns the week of the month -- useful for generating a logfile name for a given date in the format yymmww function getWeek($date) { $stamp = is_string($date) ? strtotime($date) : $date; $week = ceil(date('j', $stamp) / 7); if (date('w', $stamp) < date('w', mktime(0,0,0, date('m', $stamp), 1, date('Y', $stamp)))) { $week++; }// if return $week; } getWeek('11/16/2003'); // returns 4 getWeek('08/26/2003'); // returns 5 getWeek('03/02/2003'); // returns 2 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36113 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36113&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36113&report=yes

« previous php.notes (#57149) next »