strtotime(); Help
Moderator: General Moderators
strtotime(); Help
If I have a field labeled 'date' in a database and I want to determine what date it will be 3 months from that 'date'.
In this example my 'date' field=2007-08-03 so I want to have PHP determine what 3 months from that date will be.
I have tried using strtotime but I am coming up with no solution.
In this example my 'date' field=2007-08-03 so I want to have PHP determine what 3 months from that date will be.
I have tried using strtotime but I am coming up with no solution.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
What have you tried using strtotime()?
Yes. Like this:
Code: Select all
<?php
echo date($row["date_ordered"], strtotime("+3 months"));
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Code: Select all
<?php
echo date('m/d/Y', strtotime($row["date_ordered"], '+3 months'));
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Sorry, had it wonky. Try this:
Code: Select all
<?php
echo date('m/d/Y', strtotime('+3 months', strtotime($row["date_ordered"])));
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA