Old 13-06-2007, 09:47   #1 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,717
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, 09:52   #2 (permalink)
stickmus
hmmm...
 
stickmus's Avatar
 
Join Date: Jan 2004
Location: Yorkuk
Posts: 2,130
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, 09:59   #3 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,717
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, 10:14   #4 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,717
$yday=strtotime("-1day");
$newdate=date("d-m-Y", $yday);
echo $newdate;


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

  Reply With Quote
Old 13-06-2007, 10:34   #6 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,717
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, 10:50   #7 (permalink)
pgo
i'm done, son
 
Join Date: Jan 2005
Posts: 12,262
Nope, I use it all the time.
  Reply With Quote
Old 13-06-2007, 12:25   #8 (permalink)
gk
geek
 
gk's Avatar
 
Join Date: Oct 2006
Location: *.everywhere
Posts: 204
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, 13:47   #9 (permalink)
pgo
i'm done, son
 
Join Date: Jan 2005
Posts: 12,262
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 14-06-2007, 19: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 14-06-2007, 20:06   #11 (permalink)
Snowshiro
Will work for Marmite
 
Snowshiro's Avatar
 
Join Date: May 2007
Location: Sapporo, Japan
Posts: 574
echo date("d-m-Y", strtotime("yesterday"));
  Reply With Quote
Old 18-06-2007, 08:15   #12 (permalink)
combat sheep
Trained to Kill.
 
combat sheep's Avatar
 
Join Date: Oct 2006
Location: Southport, UK
Posts: 308
Send a message via MSN to combat sheep
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 - Top
Search Engine Optimization by vBSEO 3.0.0 RC8