PHP Acquisition System Time _php Tutorial

Source: Internet
Author: User
Tags echo date iso 8601 iso 8601 format
See someone on the Internet, but not particularly specific, I am a novice, so it looks tired, so I have read the Manual of PHP carefully, and then according to the way of thinking of the Novice wrote the following text.

There are the following expressions:

StringDate (String $format [, int $timestamp])

(note: May have just learned to the back of the [, int $timestamp] Do not understand, in fact, this expression of an optional parameter meaning, that is, you can fill, or do not fill, not to say that the date function does not need this parameter, but this parameter at the time of definition has been assigned value, If parameters are passed in, the default parameters such as date (int a,int b=1) are used, where B is already defined)

(Note: $format to add a $ symbol before changing in PHP)

First of all, the function of the back parameter $timestamp, which represents the timestamp. A valid timestamp typically ranges from 20:45:54 GMT December 13, 1901 to January 19, 2038 03:14:07. (This range conforms to the minimum and maximum values of a 32-bit signed integer). However, before PHP 5.1, this range was limited to some systems (such as Windows) from January 1, 1970 to January 19, 2038 (I tried to do so).

This is roughly the number of seconds represented by the benchmark + $timestamp from 1970.1.1, which is your current time. (In a word, if it is partial hardware, the microcontroller has RTC clock, that is, in the low power supply time, the use of 32768 crystal start counting, and then the next time the microcontroller boot, read the number of recorded, converted to time, that is. )

Other words

echo Date ("y-m-d h:i:s", 0);
?>

The 1970-01-01 12:00:00 will be displayed.

The $format has the following expression

Format character description return value example
Day------
Day of the D month, 2 digits with leading zeros 01 to 31
The day of the D-week, the text says, 3 letters Mon to Sun
Day of the J month, without leading 1 to 31
L (Lowercase letter of "L") Day of the week, full text format Sunday to Saturday
N ISO-8601 format number represents the day of the week (PHP 5.1.0 new Plus) 1 (for Monday) to 7 (represents Sunday)
S English suffix, 2 characters st,nd,rd or th, after the number of days per month. Can be used with J.
The day of the W week, the number represents 0 (representing Sunday) to 6 (for Saturday)
Days 0 to 366 in the Z-year
Week------
The week of the year in W ISO-8601 format, starting from Monday (PHP 4.1.0 New) For example: 42 (42nd Week of the year)
Month------
F month, full text format, such as January or March January to December
The month represented by the m number, with a leading 1 to 12
M three-letter abbreviation for month Jan to Dec
n number of months, without leading 1 to 12
t the number of days that a given month should be 28 to 31
Years------
L is a leap year if the leap year is 1, otherwise 0
o ISO-8601 format year number. This is the same value as Y, except if the day of the Week (W) of the ISO belongs to the previous year or the next year. (PHP 5.1.0 New) examples:1999 or 2003
Y 4-digit year full representation for example: 1999 or 2003
Y 2 digits indicate the year for example: 99 or 03
Time------
A lowercase morning and afternoon value am or PM
A uppercase morning and afternoon value am or PM
B Swatch Internet Standard 000 to 999
G-hour, 12-hour format, without leading 1 to 12
G-hour, 24-hour format, without leading 00 to 23
H-hour, 12-hour format, with leading 1 to 12
H-hour, 24-hour format, with leading 000 to 23
I have a leading zero minute number 00 to 59>
S number of seconds, with leading 000 to 59>
Time Zone------
E Time zone identifier (PHP 5.1.0 new) Example: Utc,gmt,atlantic/azores
I is daylight saving time if daylight saving time is 1, otherwise 0
O hours of difference from GMT for example: +0200
The difference between P and GMT (GMT) is separated by a colon between hours and minutes (PHP 5.1.3) For example: +02:00
T the local time zone for example: EST,MDT ("translator note" in Windows for the full text format, such as "Eastern Standard Time", the Chinese version will show "China normal times").
The number of seconds to offset the Z-time difference. The time zone offset in the west of UTC is always negative, and the time zone offset to the east of UTC is always positive. 43200 to 43200
Full Date/Time------
Date in C ISO 8601 format (PHP 5 new Plus) 2004-02-12t15:19:21+00:00
R RFC 822 Format date For example: Thu, 2000 16:01:07 +0200
The number of seconds since the beginning of the Unix era (January 1 1970 00:00:00 GMT) See the time () example:
Set the default time zone to use. Available from PHP 5.1
Date_default_timezone_set (' UTC '); Setting the time zone is important, the default time zone and Beijing time are 8 hours apart date_default_timezone_set (' PRC ');//PRC to GMT


Output similar to: Monday
echo Date ("L");

Output similar to: Monday 15th of August 2005 03:12:46 PM
echo Date (' L DS \of F Y h:i:s A ');

Output: July 1, on a Saturday
echo "July 1, is on a". Date ("L", mktime (0, 0, 0, 7, 1, 2000));

/* Use constants in format parameters */
Output similar to: Mon, 2005 15:12:46 UTC
echo Date (date_rfc822);

Output similar to: 2000-07-01t00:00:00+00:00
echo Date (Date_atom, mktime (0, 0, 0, 7, 1, 2000));
?>


Excerpt from Wolinxuebin's column

http://www.bkjia.com/PHPjc/478196.html www.bkjia.com true http://www.bkjia.com/PHPjc/478196.html techarticle see someone on the Internet, but not particularly specific, I am a novice, so it looks tired, so I have read the Manual of PHP carefully, and then follow the Novice's thinking ...

  • 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.