note 90596 deleted from function.date by tularis

From: Date: Thu, 09 Feb 2012 20:57:32 +0000
Subject: note 90596 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185991@lists.php.net to get a copy of this message
Note Submitter: guido dot orellana at gmail dot com ---- Function to obtain last week timestamps. <?php function LastWeek(){ $week = date('W'); $year = date('Y'); $lastweek=$week-1; if ($lastweek==0){ $week = 52; $year--; } $lastweek=sprintf("%02d", $lastweek); for ($i=1;$i<=7;$i++){ $arrdays[] = strtotime("$year". "W$lastweek"."$i"); } return $arrdays; } $days = LastWeek(); echo "last week between " . date('Ymd000000',$days[0]) . " and " . date('Ymd235959', $days[6]) . "\n"; ?>

« previous php.notes (#185991) next »