PHP date function date. In programming, the date format is often difficult to control, and PHP date functions are usually used. so I have studied the PHP date functions and will share them with you here, I hope that the date format in the major programming process is often difficult to control, and PHP date functions are still quite common. so I have studied the PHP date functions and will share them with you here, I hope it will be useful to you. PHP date and time functions date ()
1, year-month-day
- echo date('Y-m-j');
- 2007-02-6
-
- echo date('y-n-j');
- 07-2-6
Uppercase Y indicates four digits of the year, while lowercase y indicates two digits of the year. lowercase m indicates the number of the month (with the leading digit), while lowercase n indicates the number of the month without the leading digit.
- echo date('Y-M-j');
- 2007-Feb-6
-
- echo date('Y-m-d');
- 2007-02-06
Uppercase M indicates the three abbreviated characters of the month, while lowercase m indicates the number of the month (with the leading 0). without uppercase J, only lowercase j indicates the date of the month, no leading o; use lowercase d if the month has a leading character.
- echo date('Y-M-j');
- 2007-Feb-6
-
- echo date('Y-F-jS');
- 2007-February-6th
Uppercase M indicates the three abbreviated characters of the month, while uppercase F indicates the full English writing of the month. (No lowercase f) uppercase S indicates the suffix of the date, such as "st", "nd", "rd", and "th". for details, see the date number. Summary: The year can be uppercase Y and lowercase y; the month can be uppercase F, uppercase M, lowercase m, and lowercase n (two types of characters and numbers respectively ); indicates the date suffix.
2, hour: minute: Second
By default, PHP interprets the display time as "Greenwich Mean Time", which is 8 hours different from our local time.
- echo date('g:i:s a');
- 5:56:57 am
-
- echo date('h:i:s A');
- 05:56:57 AM
Lowercase g indicates the 12-hour system, with no leading 0, while lowercase h indicates the 12-hour system with leading 0. When the 12-hour format is used, it indicates that upper afternoon, lower case a indicates lower case "am" and "pm", and upper case A indicates upper case "AM" and "PM ". Uppercase G indicates the number of hours in the 24-hour format, but does not contain the leading value. uppercase H indicates the number of hours in the 24-hour format. Conclusion: the letter g indicates that the hour does not have a leading character, and the letter h indicates that the hour has a leading character; the lowercase g, h indicates 12 hours, and the uppercase G and H indicate 24 hours. The above is a simple PHP date function year-month-day, hour: minute: second introduction, hope to help everyone.
...