Change language

How do I get the current year in PHP?

date (format, timestamp) 
Explanation :
  • The format parameter to the date() function specifies the format of the date and time returned.
  • The time stamp is optional. If not enabled, the current date and time will be used.
To get the current year as four digits, Y is used as a parameter to date(), as shown below: Program :
// PHP program for getting
// current year echo "Current Year is:" ;  
// Save the year
// variable $year = date ( "Y" );  
// Display year echo $year ;  
Current Year is : 2019 
formatting parameters available in the date() function:the formatting parameter of the date() function is a string that can contain several characters, allowing to generate dates in different formats, are listed below:
  • d - represents the day of the month. Two digits with leading zeros (01 or 31) are used.
  • D - represents the day of the week in text (Monday through Sunday).
  • m - represents the month in numbers with leading zeros (01 or 12).
  • M - represents the month in text, abbreviated (January to December).
  • y - represents the year in two digits (08 or 14).
  • Y - represents the year in four digits (2008 or 2014).


Best laptop for Sims 4


Best laptop for Zoom


Best laptop for Minecraft


Best laptop for engineering student


Best laptop for development


Best laptop for Cricut Maker


Best laptop for hacking


Best laptop for Machine Learning


Latest questions


psycopg2: insert multiple rows with one query

12 answers


How to convert Nonetype to int or string?

12 answers


How to specify multiple return types using type-hints

12 answers


Javascript Error: IPython is not defined in JupyterLab

12 answers


Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method