PHP date

How to Have the Current Year Written by Using Function Date PHP



Almost all websites have a footer with copyright information where you can usually find the current year as well. The most comfortable way to make it appear is date PHP.



This drawing provides you the really simple solution to get the current date written.

  • d – day
  • m – month
  • Y – year

You will see the following result:


Date PHP

Let’s check this example below for date PHP which can be used in a footer:

I’ve just tested the code and the output is:
Copyright © 2013


For a website that is older than 1 year you should use the following:

I got the following after testing it:
Copyright © 2000 – 2013


You must use capital Y because small y gives you 13 instead of 2013.

I hope this article makes it easier for you to have your footer updated. You can take a look at the official date php manual if you want to know more about the date PHP function.

It’s important to know that PHP scripts are being executed on server-side, which means that the date can be different if your time-zone is UTC-8 and your visitor is from UTC-5. As a solution for this problem you can use JavaScript getTimezoneOffset().

I personally don’t really like JS codes but I know they are essential parts of websites. If you stick to PHP you can give a try to localize visitor time-zone by checking his IP address. You can read about the method here.

However, if you analyze your visitor’s IP address (or check browser settings with the JS code) you should make this clear in your privacy policy page.

Is there anything else? Oh, right, the time output, I nearly forgot it:



Posted by:

Balazs Hende
I am a blogger and the founder of this site. I have started on October 1, 2013. Have a pleasant stay here!

Related articles

Random article #1


Back to Top