find the current year in php

To find the current year in PHP, you can use the built-in date() function with the Y format code, which represents the year with four digits.

Here's an example code block that demonstrates how to get the current year in PHP:

main.php
<?php
$year = date("Y");
echo "The current year is: " . $year;
?>
66 chars
5 lines

This will output something like:

main.php
The current year is: 2021
26 chars
2 lines

related categories

gistlibby LogSnag