Over the past few months I have been working on time and Dates functions for my works and was finding it a little confusing at first as I didn’t find any easy reference for Dates & Time formatting in PHP. I did thought of making a reference table from the time I was redesigning my blog but couldn’t due to some or the other reason any way here it is
I did work a little on managing Time Zones with PHP but I skipped to make a cheat sheet for formatting using PHP
date() function. The date/time functions allow you to get the date and time from the server and also to format the date and time in several ways.
date() function takes in 2 arguments, first is formatting string that is what this article is about and the second a UNIX timestamps, that is time in the number of seconds since the Unix Epoch.
Note : PHP will give a warning not to rely on the system’s timezone settings if you haven’t set time Zone refer Time Zones with PHP to set it.
The following is a reference table of common PHP dates, time stamp used for demo is
|MySQL DATETIME format
|Time in Hour, Minuet’s and seconds
|Date in Day, Month and Year (2 digits)
|Date in Day, Month and Year ( 4 Digits )
|Numeric contractions for ordinals
l dS F Y
Thursday 05th March 2015
|Expanded human laymen readable form
If you want to try out the values with a custom time stamp check out the demo.