日期戳功能在PHP中

I'm trying to make a subscription based system, once a person registers he/she can choose a package for 1/3/6 months and pay for it, once the payment is successful, a date stamp is added, this date stamp is based on the package i.e if the package is purchased today it will be of the same day 3 months ahead or 1 month or whatever.

I'm having problems creating a function that solves this.

Let's say your package subscription is for 3 months from now. You can get that date like this:

echo date('Y-m-d H:i:s', strtotime('+3 months', time()));

This worked for me, thanks everyone!

$dateNow = new DateTime();
$dateAhead = $dateNow->add(DateInterval::createFromDateString('3 months'));
print $dateAhead->format('Y-m-d');
/**
 * @param $month your package subscription is for $month months from now
 * @param string $format
 * @return bool|string
 */
function subscription($month, $format = 'Y-m-d H:i:s')
{
    return date($format, strtotime('+' . $month . ' months', time()));
}