PHP: How to get Current Date

There are multiple ways which can be used to get PHP Current Date, I’m going to start with the simplest way.

the date will return a string

According to PHP Manual, date() takes two parameters, the first one is format the second one is timestamp.

Breaking down the Format i used:

YA full numeric representation of a year, 4 digits
mNumeric representation of a month, with leading zeros
dDay of the month, 2 digits with leading zeros
H24-hour format of an hour with leading zeros
iMinutes with leading zeros
sMinutes with leading zeros
dash will be rendered as it is, since it’s not a format code

the format is how you want the date to be outputted, for a list of available formats go to

that’s the simplest way to output a date. you can specify the timestampif you don’t want the date to be the current date/time, using the function time(), or from a valid timestamp string.

The Second way is using the DateTime() class.


The DateTime can do much more than what date can do, i will cover that in another post.

That’s it for now, a very simple post covering PHP Date.