Reputation: 5974
Suppose I pull a field from the database, a timestamp field.
How do I get the Unix Timestamp, 1 month in the future, from that timestamp field?
My brain is a bit tired, so I need a bit of a re-jogging.
Upvotes: 10
Views: 34584
Reputation: 82028
Depends on the database.
(Don't know the others, sorry)
Of course there is also strtotime('+1 month', $current_time);
in PHP. Of course, strtotime is so incredibly easy you might consider it cheating ;-).
Upvotes: 2
Reputation: 117
How about something like:
tm *currTime = localtime(timestamp);
currTime->tm_mon++;
timestamp = mktime(currTime);
Upvotes: -2
Reputation: 401002
I would use the strtotime()
function, to add +1 month
to your timestamp :
$future = strtotime('+1 month', $current_time);
After all, adding one month to a date is a bit harder that adding 30243600 seconds...
Upvotes: 7
Reputation: 62392
$newDate = strtotime('+1 month',$startDate);
Using strtotime() you can pass it '+1 month' to add a context sensitive month.
Upvotes: 25