You are here: Re: Date, beginning of week « All PHP « IT news, forums, messages
Re: Date, beginning of week

Posted by Steve on 03/02/07 15:30

"Steve" <no.one@example.com> wrote in message
news:opXFh.7$Xo3.4@newsfe03.lga...
|
| "Brian" <brian_no_spam@nrwp.co.uk> wrote in message
| news:Q9XFh.41373$Fm2.13741@newsfe1-gui.ntli.net...
||
|| "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
|| news:op.tokf4812qnv3q9@misant...
|| > Does it go back to the previous Monday if the current day is a Monday?
||
|| Yes always the week before, so even if it's Monday still go back a week,
| if
|| it;s
|| Wednesday, then go back 1 week and 2 days
||
|| I need to end up with 2 timestamps from the priviose week starting on the
|| monday
|| at 00:00:00 and ending on the Sunday at 23:59:59
|
|
| so whatever today is, get the date of last week's monday. this is the
start
| date. from there, the following sunday is the end date...right?
|
| $today = strtotime(date('m/d/Y') . ' 00:00');
| $monday = strtotime('last monday', $today);
|
| // at this point, $monday is either the monday of the same
| // week as $today or, it is the monday of the week prior
| // to the week of $today
| // find out here:
|
| if (intval(strftime('%w', $today)) != 0)
| {
| // $today is NOT monday, so we need to get
| // last week's monday
|
| $monday = strtotime('last monday', $monday);
| }
|
| // either way, sunday is determined by $monday
|
| $sunday = strtotime('next sunday', $monday);

ok...just saw the the end date should be the last second of sunday. add this
as your final line of code:

$sunday = strtotime(date('m/d/Y', $sunday) . ' 24:59:59');

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация