How to Get the Current Year using PHP
Topic: PHP / MySQLPrev|Next
Answer: Use the PHP
You can simply use the PHP
date() function to get the current year.
The following example code will be very useful if you want to put a copyright notice in a website footer without worrying about changing it every year.
ExampleTry this code »
<p>Copyright © <?php echo date("Y"); ?> MyWebsite. All Rights Reserved.</p>
Here are some more FAQ related to this topic:
- How to extract substring from a string in PHP
- How to combine two strings in PHP
- How to convert a string to uppercase in PHP