Old 13-06-2007, 14:47   #1 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 6,837
yesterday in PHP

Can anyone tell me is there a simple way to retrieve yesterday's date in PHP?

Thanks.
__________________
  Reply With Quote
Old 13-06-2007, 14:52   #2 (permalink)
stickmus
hmmm...
 
stickmus's Avatar
 
Join Date: Jan 2004
Location: Yorkuk
Posts: 2,126
PHP: strtotime - Manual

PHP Code:
strtotime("-1 day"
__________________
George Smith - a vain attempt to get higher on google for my name

  Reply With Quote
Old 13-06-2007, 14:59   #3 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 6,837
Thanks. Dates are a real blind spot for me.

Is it easy for you to tell me how to get that to 13-06-2007 format or shall I get a book out?
__________________
  Reply With Quote
Old 13-06-2007, 15:14   #4 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 6,837
$yday=strtotime("-1day");
$newdate=date("d-m-Y", $yday);
echo $newdate;


Thanks.
__________________
  Reply With Quote
Old 13-06-2007, 15:14   #5 (permalink)
stickmus
hmmm...
 
stickmus's Avatar
 
Join Date: Jan 2004
Location: Yorkuk
Posts: 2,126
__________________
George Smith - a vain attempt to get higher on google for my name

  Reply With Quote
Old 13-06-2007, 15:34   #6 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 6,837
I can make neither head nor tail of PHP online manual, is it just me??

Fixed now anyways. Thanks again.
__________________
  Reply With Quote
Old 13-06-2007, 15:50   #7 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,334
Nope, I use it all the time.
  Reply With Quote
Old 13-06-2007, 17:25   #8 (permalink)
gk
geek
 
gk's Avatar
 
Join Date: Nov 2006
Location: *.everywhere
Posts: 233
Send a message via ICQ to gk Send a message via AIM to gk Send a message via MSN to gk Send a message via Yahoo to gk
Yep I use it all the time.

If you are on windows I recommend you download the CHM for faster searching.

PHP: Get Download

It's great but it lacks the comments which is no biggie.
__________________
Quote:
"Why reinvent the wheel"? Simply because it's not round enough and I don't like the treads.
  Reply With Quote
Old 13-06-2007, 18:47   #9 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,334
Yeah, I recently purchased PHP Designer 2007, which is good, but has a few minor irritations (was only $50 though). You can embed the PHP manual into it, so you put your cursor on a function and hit "F1" and the manual pops up.

Pretty handy, but I'm still used to just going to the browser and typing "php.net/function_name"!
  Reply With Quote
Old 15-06-2007, 00:48   #10 (permalink)
rfresh
Registered User
 
Join Date: Jun 2007
Location: Los Angeles
Posts: 33
I use the PHP online help manual at this URL:

php dot net

and find it's format pretty easy to follow.

RalphF
GoldRushWebHosting com
  Reply With Quote
Old 15-06-2007, 01:06   #11 (permalink)
Snowshiro
Will work for Marmite
 
Snowshiro's Avatar
 
Join Date: May 2007
Location: Sapporo, Japan
Posts: 570
echo date("d-m-Y", strtotime("yesterday"));
  Reply With Quote
Old 18-06-2007, 13:15   #12 (permalink)
combat sheep
 
Posts: n/a
make sure you set a date_default_timezone_set or you will get errors on your web server (if php is set to E_STRICT) which is should be.
  Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive
vBulletin © 2000-2009 Jelsoft Enterprises Limited.
Search Engine Optimization by vBSEO 3.0.0 RC8