Tenth chapter date and time _php tutorial

Source: Internet
Author: User
Tags php language php programming posix

Learning Essentials:
1.PHP Date and Time library

When you are programming with PHP, the date and time are very different compared to most other types of data that you encounter.
Because dates and times do not have a clear structure, and the calculation and presentation of dates is cumbersome. In PHP, date and time
Library is a core part of the PHP language.

The timestamp is the number of seconds since January 1, 1970 (00:00:00 GMT). It is also known as UNIX time
Stamp (Unix Timestamp). Unix Timestamp (Unix timestamp), or Unix time (Unix times), POSIX
(POSIX time), which is a temporal representation defined as from GMT January 01, 1970 00 o'clock 00
The total number of seconds from 00 seconds to the present. Unix timestamps are not only used in UNIX systems, Unix-like systems, but also in
Are widely used in many other operating systems. For example (1184557366 = 2007-07-16 03:42:46)

A PHP Date and Time library

Verified Date: Thecheckdate() function verifies the date well and returns true if the supplied date is valid.
Otherwise, false is returned.

 
  < span="">(< span="">  2,29,2007< span="">  < span=""> ' date valid  '    < span="">  < span=""> ' Date < span="">is illegal '?>  < span="">  < span="">

Format time and Date: thedate() function returns a string that formats the time and date according to a predefined instruction.
All format parameters can be referenced in the manual.

 
  < span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">?>

See more time information:gettimeofday() function returns an association of elements that are related to the current time
Group.

 
  < span="">< span="">(?>< span="">< span="">

Converts a timestamp into a friendly value: thegetdate() function takes a timestamp and returns a component that consists of its parts
An associative array of. If the parameter is not given, then the current time and date are returned.

 
  < span="">(< span="">(1184557366< span="">?>

Gets the current timestamp: thetime () function can get the current timestamp and can be set by the timestamp value.

 
  < span="">< span="">(' y-m-d h:i:s ',< span="">() + (7*24*60*60< span="">?>

Gets a specific timestamp: themktime() function can generate a timestamp for a given datetime.

 
  < span="">< span="">< span="">(14,14,14,11,11,2007< span="">< span="">(' y-m-d h:i:s ',(< span=""> 14,14,14,11,11,2007< span="">?>

Calculate Time Difference

 
  < span="">< span="">< span="">< span="">< span="">(< span="">0,0,0,7,17,2010< span="">(< span="">  < span="">  )/60/60< span="">?> < span="">

Converts a date to a timestamp:strtotime() converts a human-readable date to a Unix timestamp.

 
  < span="">< span="">(' 2007-10-31 14:31:33 '< span="">?>

Calculate Time Difference

 
  < span="">< span="">(< span="">(' 2007-10-31 11:31:33 '))/60/60?>< span="">

Gets the current file last modified:getlastmod() Gets the timestamp of the last modification time of the current file.

 
  < span="">< span="">(' y-m-d h:i:s ',< span="">< span="">?>

set the time zone and GMT/UTC:
Modify the settings in the php.ini file to find the [date], Date.timezone = option, and modify the item to
Date.timezone=asia/shanghai, and then restart the Apache server.


putenv () function to set the current default time zone.

 
  < span="">(< span="">< span="">' Tz=asia/shanghai'< span="">(' y-m-d h:i:s '  ) < span=""> ?>

Date_default_timezone_set () to set the current default time zone.
Date_default_timezone_get () to get the current default time zone.

 
  '< span="">< span="">asia/shanghai '< span="">(' y-m-d h:i:s '?>< span="">

Get local time localtime() function can get local time data, and then return an array.

 
  ' Asia/shanghai '< span="">< span="">  ( < span="">  < span="">  < span="">((?>< span=""> < span=""> < span="">< span="">

Calculate page script run time: themicrotime() function, which returns the current UNIX timestamp and the number of microseconds. Return
A string that is formatted as msec sec, where the SEC is the current Unix timestamp and msec is the number of microseconds.

 
  < span="">< span="">< span="">(< span="">< span="">< span="">< span="">< span="">< c19>  + =    < span="">  < span="">< span="">    < span="">  < span=""> < span="">(=0;  < span="">  < span=""> <1000000; < span="">++< span="">< span=""> =< span="">< span="">  < span="">(< span="">, 4?>< span=""> < span=""> 

Note: The article is from Eon to PHP video tutorial, this article is limited to exchange use, not for commercial purposes, otherwise the consequences.

http://www.bkjia.com/PHPjc/759629.html www.bkjia.com true http://www.bkjia.com/PHPjc/759629.html techarticle Learning Essentials: 1.PHP Date and Time library when you use PHP programming, the date and time are very different than most other types of data that you encounter. Because the date and time are not clear ...

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