How to get next year in PHP?

by jasen_gottlieb , in category: PHP General , 5 months ago

How to get next year in PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by ryan.murray , 3 months ago

@jasen_gottlieb use DateTime() object to get next year in PHP, code:


1
2
3
4
5
6
7
8
<?php

$nextYear = new DateTime("+1 year");

// Output: 2023
echo $nextYear->format("Y");
// Output: 23
echo $nextYear->format("y");