Quick date function question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Quick date function question

Post by seodevhead »

Hey guys...

If..

Code: Select all

echo date('d');
# Outputs 'Mon'
How can I do the same for 3 days ago (Fri)? I can't seem to figure out how I can say to php, output the 3 letter abbreviation for the day that took place 3 days ago. Any guidance is appreciated. Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post by seodevhead »

feyd wrote:date() + strtotime()
Hey feyd, I'm looking at strtotime() right now and am a little confused. It doesn't seem to show any output for the examples on the manual, but I gather it just takes the current or supplied timestamp and performs adjustments on that based on the first parameter in the function.

I am trying:

Code: Select all

$dayAbbrev = date('D') + strtotime("-1 day");
But it isn't working. Any further hints on where I'm going wrong here? Thanks feyd.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Code: Select all

<?php
echo date('d', strtotime('-3 days'));
?>
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post by seodevhead »

May God Bless both Everah and feyd for their help and kindness :)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

He has. And you are welcome.
Post Reply