-1

I'm looking at making an automated post once a week blog so I can create more postings and then have them go out once a week. I'm having some trouble getting the greatest time and adding 1 week to it.

My database I'm using "datetime". So the string is in "2013-03-20 09:42:41".

I can get the value of greatest post blog_date, but how do I add 1 week to the string?

date('$blog_date', strtotime("+1 week"));

Thanks for your time ^^

ANSWER WORKS:

$blog_date = date('Y-m-d h:i:s', strtotime("+1 week", strtotime($newest)));
hobbywebsite
  • 133
  • 1
  • 2
  • 13
  • same question here : http://stackoverflow.com/questions/6086389/php-date-format-yyyy-mm-dd-minus-or-add-one-week-from-now – Sumit Bijvani Mar 16 '13 at 17:31

2 Answers2

1

You can use the Datetime object to add a week easily

http://php.net/manual/en/book.datetime.php

$date = new DateTime('2013-03-20 09:42:41');
$date->modify('+1 week');
Tuim
  • 2,491
  • 1
  • 14
  • 31
1

Try this..

$blog_date = "2013-03-20 09:42:41";
$date2 = strtotime(date("Y-m-d", strtotime($blog_date)) . "+1 week");
echo date('Y-m-d', $date2);

Output

2013-03-27
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82