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

Posted by Brian on 03/02/07 16:10

"Steve" <no.one@example.com> wrote in message
news:0sXFh.8$Xo3.1@newsfe03.lga...
> |
> | $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');
>
Hi Steve

Am I missing soothing here, the Monday is correct, but I can't see how you
are working out the Sunday, if I run the script I get the following

Monday = Mon 19 Feb 07 00:00:00 am
Sunday = Mon 19 Feb 07 23:59:59 pm

is should be

Monday = Mon 19 Feb 07 00:00:00 am
Sunday = Sun 25 Feb 07 23:59:59 pm

Sorry to be a pain, I hate dates and timestamps !

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(date('m/d/Y', $monday) . ' 23:59:59');

$realstartdate = date("D j M y H:i:s a", $monday);
$realenddate = date("D j M y H:i:s a", $sunday);

Thanks


Brian



--------------------------------------------------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 173 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!

 

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

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