Home > Tips & Tricks > Automatic Copyright Year in PHP

Automatic Copyright Year in PHP

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

Being Tricky 😉

Photo of author

About Aman Mehra

Hey there! I'm Aman Mehra, a full-stack developer with over six years of hands-on experience in the industry. I've dedicated myself to mastering the ins and outs of PHP, WordPress, ReactJS, NodeJS, and AWS, so you can trust me to handle your web development needs with expertise and finesse. In 2021, I decided to share my knowledge and insights with the world by starting this blog. It's been an incredible journey so far, and I've had the opportunity to learn and grow alongside my readers. Whether you're a seasoned developer or just dipping your toes into the world of web development, I'm here to provide valuable content and solutions to help you succeed. So, stick around, explore the blog, and feel free to reach out if you have any questions or suggestions. Together, let's navigate the exciting world of web development!

Leave a Comment