Dear friends, In this post we are going to describe the all date format in PHP. Most of developers are not aware about the PHP date methods. Suppose if i want to get the time in PHP using date and time method then we need to write the code into something like this “date(‘h:i:s’)” and some of others developers write something like this “date(‘H:i:s’)”. But there is the major difference between the “date(‘h:i:s’)” and the “date(‘H:i:s’)” is symbol of “h” and “H”. but both parameter have the different types of values as per PHP. Whereas small letter ‘h’ represent the unit of hour as per 12 hours clock time but the capital letter of time symbol ‘H’ represent the unit of hour as per 24 clockwise.
So guys there are a lot of thing related to time and date in PHP and how they impact your program. So let’s start:
Content : What are the PHP date and time formats ?
d – Represent Day of the month between 01-31
D – Represent day in form of (Mon, Tue…)
j – Represent day of the month without zeros 1 to 31.
l (lowercase ‘L’) – Textual representation of a day
N – Numeric representation of a day (1 for Monday and 7 for Sunday)
S – For English suffix 2 characters st, nd, rd or th. with j.
w – A numeric representation of the day like 0 for Sunday to 6 for Saturday
z – The day of the year in form of numerical 0-365.
W – Week number of year
F – Full textual representation of a month like January …
m – Numerical representation of a month like 01-12
M – Months in a 3 letters like Jan, Feb
n – Numerical representation of months like 1-12
t – Get the number of days in a month.
L – Check the leap year in 1/0 form. 1 represent year is a leap year and 0 represent non leap year.
o – Year in a number form
Y – Represent the four digits of the year.
y – Represent the year in 2 digits.
a – In Lowercase am/pm.
A – AM/PM in uppercase.
B – Swatch Internet time in form of 000-999
g – Time in 12 hours of form 1-12
G – Show the 24 hours clock time from 00 – 23.
h – Show the time of 12 hours clock with zero like 01-12
H – 24-hour format of an hour (00 to 23)
i – Represents the minutes with the leading of zero like 01-59
s – Represent the seconds with leading of zero like 00-59.
u – Represent the milliseconds that added after PHP 5.2.2 version.
e – Identifier of time zone.
I (capital i) – Date in day time saving time in 0-1 form
O – Difference of time in Greenwich in form of hours.
P – Difference in hours and seconds as Greenwich. This feature added after PHP 5.1
T – Represents abbreviation of time zone like EST, MDT.
Z – Show time zone offset in seconds.
c – Represent ISO based date and time format with GMT.
r – Represent day, date and time in form of (Fri, 12 Apr 2013 12:01:05 )
U – Represents seconds in form of Unix.
So, Guys these all above codes mostly used in PHP when a developers works on a project like Online ticket booking, Attendance applications, Events applications, Trigger events, in Gaming etc.
So i hope you all guys understood this concept very well. If you have some suggestion and point related to this post then you can mention below in the comment box. Thanks and cheers.