Y-m-d 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
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Y-m-d question

Post by Addos »

Code: Select all

// TEST
$date_due = '2009-10-03';
echo 'date due 2 weeks ago' . date($date_due, strtotime('-2 weeks'));// Want this to show 2009-09-19   
Is there anyway I can substitute Y-m-d with a variable like above? I want to return a few values based on the current date minus 2 weeks but this doesn’t work and I’m not sure how to approach this other than a timestamp and work it out in seconds.

Any help would be great
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Y-m-d question

Post by requinix »

Take a second (or first) look at how you're supposed to use date.
Post Reply