Re: yesterday's day of week

From: Date: Sun, 18 Aug 2002 04:41:02 +0000
Subject: Re: yesterday's day of week
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-113108@lists.php.net to get a copy of this message
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 (letkk@sk.sympatico.ca) 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. >

« previous php.general (#113108) next »