Re: [PHP] yesterday's day of week

2002-08-17 Thread Justin French

There is a magic little function called strtotime()... it takes just about
any english phrase, and acts on it... there are examples in the manual:

http://www.php.net/manual/en/function.strtotime.php

In this case, I'm guessing you'd want

$yesterday = strtotime('yesterday');


Another approach would be to get the current time stamp (or any time stamp),
and minus 24 hours from it:

60 seconds * 60 minutes * 24 hours = 86400 seconds.

$yesterday = time() - 86400;


Either way, you've got a timestamp (seconds since some date in 1970)
representing yesterday, which you can feed into date():

echo date('l',$yesterday);
echo date('d',$yesterday);
echo date('D',$yesterday);

etc etc


Justin French


on 18/08/02 11:38 AM, Kenton Letkeman ([EMAIL PROTECTED]) wrote:

> I have been able to get yesterdays date
> eg. $yesterday = date('d')-1;  result is "17"
> but am having trouble getting yesterdays day of the week.
> eg. $yesterday = date('D')-1;  result is "-1"
> eg. $yesterday = date('l')-1;  result is "-1"
> 
> Is there something I am missing?  I cannot find the documentation on this.
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] yesterday's day of week

2002-08-17 Thread Jason Wong

On Sunday 18 August 2002 09:38, Kenton Letkeman wrote:
> I have been able to get yesterdays date
> eg. $yesterday = date('d')-1;  result is "17"
> but am having trouble getting yesterdays day of the week.
> eg. $yesterday = date('D')-1;  result is "-1"
> eg. $yesterday = date('l')-1;  result is "-1"
>
> Is there something I am missing? 

You're trying to subtract 1 from a string.

> I cannot find the documentation on this.

I'm flabbergasted -- where did you look?

The proper way of doing this (ie getting yesterday's day of week and not 
subtracting 1 from a string) is to look at the examples in manual.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Who loves not wisely but too well
Will look on Helen's face in hell,
But he whose love is thin and wise
Will view John Knox in Paradise.
-- Dorothy Parker
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php