How to get after 6 month date in M / Y format? i try like this one but not working..
$regDate = "Jan / 2013";
$validTill = date('M / Y',strtotime("+6 months", strtotime($regDate)));
Best way is use DateTime object to convert your date.
$regDate = "Jan / 2013";
$myDateTime = DateTime::createFromFormat('M / Y', $regDate);
$myDateTime->modify('+6 Months');
echo $myDateTime->format('M / Y');
Note: It will support for PHP 5 >= 5.3.0 only.
Convert the format to be readeable by strtotime
.
$regDate = 'Jan / 2013';
// this should look likes this: 2013-01-01
Than your code will works.
And i Think better to store the dates in YYYY-MM-DD
format (or as unix timestamp
, but in this case you should use correct time-zone
) , and when you show, convert it to the format what you need to display.