PHP date; How to find the next year?

前端 未结 8 1681
生来不讨喜
生来不讨喜 2021-01-07 18:27

I want to get today\'s date + one year. How do I achieve this with PHP\'s date functions?

相关标签:
8条回答
  • 2021-01-07 18:33

    The shortest version:

    echo (int)date('Y') + 1;
    
    0 讨论(0)
  • 2021-01-07 18:34
    $Ad_year = 2015-10-20
    <?php echo $Ad_year + 1?>
    Result 2016
    
    0 讨论(0)
  • 2021-01-07 18:37

    Best and easy solution... You can change month or year or day.

    date('Y-m-d',strtotime("+1 day +2months +1 year"));
    
    0 讨论(0)
  • 2021-01-07 18:40

    You can use strtotime and date

    $date = '2010-09-16';
    echo date('Y-m-d', strtotime("+12 months $date"));
    // 2011-09-16
    

    On a sidenote: DateTime questions like this have been answered over and over again, so you could have found how to add to a date easily by using the search function.

    0 讨论(0)
  • 2021-01-07 18:42

    If you're working with timestamps

    echo time()+60*60*24*365
    
    0 讨论(0)
  • 2021-01-07 18:46
    echo date('Y', strtotime('+1 year'));
    
    0 讨论(0)
提交回复
热议问题