Reputation:
I have a timestamp $timestamp. How do I add 6 months to that timestamp using strtotime?
I was thinking of doing
$date = date('Y-m-d H:i:s', $timestamp);
$sixmonths_fromnow = strtotime('+6 months', $date);
but can I use strtotime directly on the timestamp? do I have to use the date() function first?
Upvotes: 2
Views: 5386
Reputation: 78994
You need to use the timestamp
:
$sixmonths_fromnow = strtotime('+6 months', $timestamp);
echo date('Y-m-d H:i:s', $sixmonths_fromnow);
Upvotes: 5