How to get current year in PHP?

The Date is an inbuilt capacity used to design the timestamp. The PC stores date and time in UNIX Timestamp. This time is estimated as various seconds since Jan 1, 1970. Since this is unrealistic for people to peruse, PHP changes over timestamp to a configuration that is lucid and more justifiable to people.

date( format, timestamp )

The accompanying model code will be exceptionally valuable to place a copyright notice in a site footer without stressing over transforming it consistently.


Try this code »

<p>Copyright © 
    <?php echo date("Y"); ?> 
MyWebsite. All Rights Reserved.</p>


The configuration boundary in the date() work indicates the arrangement of returned date and time.
  • The timestamp is a discretionary boundary. Assuming it is excluded then the current date and time will be utilized.
  • To get the current year as four digits, Y is utilized as a boundary to date() work as displayed in the underneath:


// PHP program to get the
// current year
echo "Current Year is :"
// Store the year to
// the variable
$year = date("Y"); 
// Display the year
echo $year

Current Year is :2019

Design choices accessible in date() work: The configuration boundary of the date() work is a string that can contain different characters permitting to create dates in different organizations are recorded beneath:

  • d – Represents the day of the month. It utilizes two digits with driving zeros (01 or 31).
  • D – Represents day of the week in the message (Mon to Sun).
  • m – Represents month in numbers with driving zeros (01 or 12).
  • M – Represents month in message, curtailed (Jan to Dec).
  • y – Represents year in two digits (08 or 14).
  • Y – Represents year in four digits (2008 or 2014).

PHP is a server-side prearranging language planned explicitly for web improvement. You can gain PHP starting from the earliest stage by following this PHP Tutorial and PHP Examples.

Also Read: How to Install Chrome in Ubuntu?

Leave a Reply

Your email address will not be published. Required fields are marked *