|
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]
|