PHP Date() Function

PHP date() function tutorial will explain you how to convert date and time format? with example.

PHP date() function allow you to extract and format the date or time on the server.

This function converts a date or time into a readable format.

Syntax For PHP date() Function:

  • format – A string format of the outputted date. Ex: “D, d M Y H:i:s” => “Mon,15 Aug 2012 15:42:01 +0000”
  • timestamp – An integer Unix timestamp. It’s optional.

What is Timestamp?

The timestamp is the number of seconds from January 1 1970 00:00:00 GMT else it is UNIX Timestamp.
timestamp function returns a formatted date string, or False on error.

Example on PHP Date() function :

Output will be:

PHP date and time

If you want to get and use the Unix timestamp for a date, you can use the mktime() function.

Syntax for Unix timestamp :

Example on PHP date and time:

Output will be:

Previous articleAdvanced PHP Tutorials
Next articlePHP Include File
I am a young Information Systems Security Engineer(CEH). I had started with penetration testing when i am 17 years old. It all started with Kali linux and Metasploit.In free time i will play with Security holes/Bug bounty/Pentesting and Hacking !!!