PHP datetime date () and time () function _php Tutorial

Source: Internet
Author: User
Tags echo date time and date
This article describes the usage of the two date-time function Date,time common in PHP, and friends who need it can refer to this article.

A simple way to tell you:

The code is as follows Copy Code
Echo ("Result with date ():
");
Echo (Date ("L"). "
");
Echo (Date ("L DS of F Y h:i:s A"). "
");
Echo ("Oct 3,1975 is on a". Date ("L", Mktime (0,0,0,10,3,1975)). "
");
Echo (Date (date_rfc822). "
");
Echo (Date (Date_atom,mktime (0,0,0,10,3,1975)). "

");

Echo ("Result with Gmdate ():
");
Echo (Gmdate ("L"). "
");
Echo (Gmdate ("L DS of F Y h:i:s A"). "
");
Echo ("Oct 3,1975 is on a". Gmdate ("L", Mktime (0,0,0,10,3,1975)). "
");
Echo (Gmdate (date_rfc822). "
");
Echo (Gmdate (Date_atom,mktime (0,0,0,10,3,1975)). "
");
?>


Syntax: string date (string format, int [timestamp]);
Function type: Time and date
return value: String

The parameters are as follows:
A-"AM" or "PM"
A-"AM" or "PM"
D-A few days, two digits, if less than two is the front 0; such as: "01" to "31"
D-Days of the week, three English letters; such as: "Fri"
F-month, full name in English; such as: "January"
H-12 hours of the hour; such as: "01" to "12"
H-hour of 24-hour system; such as: "00" to "23"
G-12 hours of the hour, less than two digits do not fill 0; such as: "1" to 12 "
G-24 hours of the hour, less than two does not fill 0; such as: "0" to "23"
I-minute; such as: "00" to "59"
J-A few days, two digits, if less than two bits do not fill 0; such as: "1" to "31"
L-Day of the week, English full name; such as: "Friday"
M-month, two digits, if less than two digits in front of 0; such as: "01" to "12"
N-month, two digits, if less than two digits does not fill 0; such as: "1" to "12"
M-month, three letters of English; such as: "Jan"
S-second; such as: "00" to "59"
S-End With English ordinal number, two English letters; such as: "th", "nd"
T-the number of days in the specified month; such as: "28" to "31"
U-Total number of seconds
W-Number of days of the week, such as: "0" (Sunday) to "6" (Saturday)
Y-year, four digits; such as: "1999"
Y-year, two digits; such as: "99"
Z-the day ordinal of a year; such as: "0" to "365"
If the displayed time is inconsistent with the system, change the php.ini configuration file.
The system defaults to UTC time
can open Php.inc
Set Date.timezone = PRC


http://www.bkjia.com/PHPjc/445316.html www.bkjia.com true http://www.bkjia.com/PHPjc/445316.html techarticle This article describes the usage of the two date-time function Date,time common in PHP, and friends who need it can refer to this article. Tell you an easy way: The code is as follows ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.