You are here: Re: Datetime within past week « PHP Programming Language « IT news, forums, messages
Re: Datetime within past week

Posted by Peter Fox on 11/20/06 10:22

Following on from Chris Hope's message. . .
>If you want to do it in PHP you can do eg:
>date('Y-m-d H:i:s', time() - 86400 * 7);

To be pedantic this isn't "last 7 days". It could be important if say a
customer makes a regular order. Suppose last Monday they managed to put
their order in at 11am but this Monday don't get round to it until
11:30am; now 'Last weeks' order won't appear in the list. To the
customer this could be confusing when last weeks order sometimes appears
and sometimes doesn't.

* It may not matter, so no need to be more complicated
* If it does then even an 'exact same time' or '(86400*7)+(60*30) could
fail when switching to daylight saving time.
* It isn't difficult to establish what '00:00:01' is when you know the
page in the manual, but once again things can go wrong at daylight
saving and beware the simple coding error.

>It's also possible to do it with mktime() eg:
>$timestamp = mktime(0, 0, 0, date('m'), date('d')-7, date('Y'))
>although there are more function calls doing it this way.
>See http://www.php.net/mktime for more details
>

--
PETER FOX Not the same since the borehole business dried up
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>

 

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

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