Reputation: 2752
I have:
PHP code: $date = date("F j, Y, g:i a");
and send this to my datebase
I use
$date = $gg['date'];
to get the date from my datebase
When I echo $date
-> June 30, 2012, 3:45 pm
The time is already set in the database with mail.php, and in ordertracking.php I'm getting that time and want to add one week to it.
So I want to add one week to: $date = $gg['date'];
$connection = mysql_connect("localhost","root","") or die ("Can't connect");
mysql_select_db("shoppingcart", $connection) or die ("Can't connect");
$ordertracking = mysql_query("SELECT * FROM `ordertracking` WHERE orderid='$orderid'");
while($gg=mysql_fetch_array($ordertracking))
{
$progress = $gg['progress'];
$date = $gg['date'];
}
mysql_close($connection)
Upvotes: 1
Views: 207
Reputation: 2908
Here some simple solution)
$date = date( 'F j, Y, g:i a' );
echo date( 'F j, Y, g:i a', strtotime( $date ) + 7 * 24 * 60 * 60 );
Upvotes: 1
Reputation: 6122
If you wnat to use the strtotime method you would do
$date = date('F j, Y, g:i a', strtotime('2012-06-30 3:45 pm +1 week'));
Upvotes: 0
Reputation: 6335
Can you try this:
$date = 'June 30, 2012, 3:45 pm';
$new_date = date("F j, Y, g:i a",strtotime(date("F j, Y, g:i a", strtotime($date)) . " +1 week"));
Hope this helps.
Upvotes: 0
Reputation: 4860
Use the DateTime
modify()
method
$dt = DateTime::createFromFormat("F j, Y, g:i a", $date);
$dt->modify('+1 week');
echo $dt->format("F j, Y, g:i a");
Upvotes: 3