Hello guys, in this trick we will see how we can print the automatic copyright year in PHP using the PHP DateTime function, so you don’t have to update it every year.
This copyright year is mostly used in the footer to show the current year. The following code only works in PHP, so you need a PHP file to print it.
Let’s see how to show the dynamic automatic copyright year in PHP.
Only Current Year
This is very easy to use. You just need a PHP file and then use the date()
function of PHP with the argument to print only the year.
Output
© 2022
Start and Current Year
In this scenario, we will print both the start year and the current year. Start year means when the website start and the current year is the running year.
In this script code, we take the start year as a static and print with the current year same as the above script.
Output
© 2019 - 2022
See Also: PHP – Date and Time Functions
Being Tricky 😉