Detailed php date formatting method

Date format is generally used php date () to complete this function is declared and defined as shown below, there are many parameters which, here in the usual year, month, day, hour, minute, second, brief weeks.

date(format,timestamp)

 

 

A, year, month, day format

Method of format: y: y lowercase only two display digits, Y: y uppercase display 4 digits

Tips: y is the first letter of the year, the more large, meaning capital is represented by the digital multi (4), lowercase two. Examples are as follows.

 

 

Second, the month of formatting method

m: Month represented by two digits, 0 up from "01" to "12"

n: represents the two-digit month, not 0s, from "1" to "12"

M: month with three English letters, English is shorthand for the month, such as 1 month expressed as Jan.

Tip: general use m to represent the English month, and easy to use lowercase. Examples are as follows.

 

Third, the Japanese method of formatting

d: Two digit daily, up 0

j: daily two-digit number, do not fill 0

S: uppercase th s plus a suffix, such as 10th

Tips: d is the first letter of the day, it is generally indicated by d j and the use of uppercase S. under special circumstances Day Examples are as follows.

 

 

Today's example shows the year, month, day to year - month - day format display can also be formatted according to their needs, year, month, day representation is the same. Examples are as follows.

 

 

 

Fourth, minutes and seconds format

Hour format:

G: 24-hour, not 0s, such as represented 1:00

g: 12 hour, not 0s, such as represented 1:00

H: 24 hour, 0s, such as 0. 1:00

h: 12 hour, 0s, such as 0. 1:00

Tip: uppercase represents 24-hour, 12-hour represents lowercase letters G are 0s regardless case, regardless of the case does not make the letters H 0. exemplified below.

 

 

Minutes and seconds respectively formatting parameters i and s.

i: the number of minutes, complement 0, from 00 to 59

s: the number of seconds, up 0, from 00 to 59

Examples are as follows.

 

 

Five weeks Format

D: letters indicate the day of the week, expressed as days of the week.

l: letters indicate the day of the week, indicate the full name for the day of the week

w: numbers indicate the week.

Examples are as follows.

 

Guess you like

Origin www.cnblogs.com/zxf100/p/11462829.html