note 85332 modified in function.date by thiago

From: Date: Tue, 26 Aug 2008 12:50:16 +0000
Subject: note 85332 modified in function.date by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143836@lists.php.net to get a copy of this message
here is the simpliest way to get the start and end date of the week; <?php $sdate=date('c',strtotime(date('Y')."W".date('W')."0")); $edate=date('c',strtotime(date('Y')."W".date('W')."7")); ?> the format is for the string in strtotime is; 2008W200 this stands for year - 2008, constant never changes - W, week number of the year - 20, day of the week - 0 for sunday, 1 for monday, etc.... so 2008W200 stands for the sunday of the 20th week of 2008. This will only work in php 5 or better --was-- here is the simpliest way to get the start and end date of the week; $sdate=date('c',strtotime(date('Y')."W".date('W')."0")); $edate=date('c',strtotime(date('Y')."W".date('W')."7")); the format is for the string in strtotime is; 2008W200 this stands for year - 2008, constant never changes - W, week number of the year - 20, day of the week - 0 for sunday, 1 for monday, etc.... so 2008W200 stands for the sunday of the 20th week of 2008. This will only work in php 5 or better http://php.net/manual/en/function.date.php

« previous php.notes (#143836) next »