The format of the date in the programming is often not good control, PHP date function is more commonly used, so I studied the PHP date function, here to take out and share with you, hope to be useful to everyone. PHP datetime function Date ()
1, year-month-day
- echo Date (' y-m-j ');
- 2007-02-6
- echo Date (' y-n-j ');
- 07-2-6
Uppercase Y represents the year four digits, while lowercase y represents the two digits of the year, the lowercase m represents the number of the month (with the leading), and the lowercase n indicates the month number without leading.
- echo Date (' y-m-j ');
- 2007-feb-6
- echo Date (' y-m-d ');
- 2007-02-06
The uppercase M represents the 3 abbreviation characters of the month, while the lowercase m represents the number of the month (with leading 0); J with no upper case, only lowercase J for the date of the month, no leading o, or lowercase D if the month with leading is required.
- echo Date (' y-m-j ');
- 2007-feb-6
- echo Date (' Y-f-js ');
- 2007-february-6th
Uppercase M represents the 3 abbreviated characters of the month, while uppercase F indicates the full written English of the month. (no lowercase f) uppercase S denotes the suffix of the date, such as "St", "nd", "rd", and "th", depending on the date number. Summary: Indicates that the year can be capitalized with Y and lowercase y, indicating that the month can be in uppercase F, uppercase M, lowercase m, and lowercase n (two ways of representing characters and numbers, respectively); The day can be in lowercase d and lowercase j, and uppercase s represents the suffix of the date.
2, Hours: minutes: seconds
By default, the PHP interpretation is displayed as "Greenwich Mean Time", which differs from our local time by 8 hours.
- echo Date (' g:i:s a ');
- 5:56:57 am
- echo Date (' H:i:s A ');
- 05:56:57 AM
The lowercase g represents a 12-hour system without a leading 0, while the lowercase h indicates a 12-hour system with a leading 0. When using the 12-hour system, it is necessary to indicate that in the afternoon, lowercase a represents the lowercase "am" and "PM", and uppercase a denotes uppercase "AM" and "PM". The uppercase G represents the 24-hour hour, but without the preamble, and the uppercase H indicates a leading 24-hour hour. Summary: The letter G means the hour without leading, the letter h for the hour with the leading; lowercase g, h for 12-hour, uppercase G, h for 24-hour system. The above is a simple PHP date function year-month-day, when: minute: the introduction of the second, I hope to help everyone.
http://www.bkjia.com/PHPjc/446513.html www.bkjia.com true http://www.bkjia.com/PHPjc/446513.html techarticle in programming the format of the date is often not good control, PHP date function is more commonly used, so I studied the PHP date function, here to take out and share with you, I hope the big ...