The difference between time (), date (), and Mktime () in PHP

Source: Internet
Author: User
Tags time and date
    1. Print (Date ("L DS of F Y h:i:s A"));
    2. Print ("July 1, is on a". Date ("L", Mktime (0,0,0,7,1,2000)));
    3. ?>
Copy Code

Example two:

    1. $tomorrow = Mktime (0,0,0,date ("M"), Date ("D") +1,date ("Y"));
    2. $lastmonth = Mktime (0,0,0,date ("M") -1,date ("D"), Date ("Y"));
    3. $nextyear = Mktime (0,0,0,date ("M"), Date ("D", Date ("Y") +1);
    4. ?>
Copy Code

Reference gmdate () mktime ()

Strftime the time of the server to be formatted locally. Syntax: string strftime (string format, int [timestamp]); return value: String function type: Time date content Description The string of the return value is determined by the configured format. If there is an incoming timestamp value, the timestamp is formatted and returned if no time stamp value is passed, and the current server's time is formatted locally. The month or week name varies with the local language configuration setlocale (). The returned string can be in the following format:

    1. SetLocale ("Lc_time", "C");
    2. Print (Strftime ("%A in Finnish is");
    3. SetLocale ("Lc_time", "fi");
    4. Print (Strftime ("%A, in French"));
    5. SetLocale ("Lc_time", "fr");
    6. Print (Strftime ("%A and in German"));
    7. SetLocale ("Lc_time", "de");
    8. Print (Strftime ("%A.N"));
    9. ?>
Copy Code

Reference setlocale () mktime ()

GetDate Get time and date information. Syntax: array getdate (int timestamp); return value: function type: Time date content Description The element that returns an array includes the following items:

"Seconds"-second "minutes"-minute "hours"-when "mday"-the Day of the month "wday"-the day of the week when the number "Mon"-The month number "year"-the number of days of the day number "Yday"-the current year; such as: "299" "weekday"-the full name of the week; such as: "Friday" "Month"-the full name of the month; such as: "January"

Gettimeofday get the current time. Syntax: array gettimeofday (void); return value: function type: Time date content Description The element that returns an array includes the following items:

"SEC"-seconds "usec"-one out of 10,000 seconds "minuteswest"-GMT "Dsttime"-the purpose of the time zone

The gmdate obtains the current time with the GMT difference. Syntax: string gmdate (string format, int timestamp); return value: String function type: Time Date content Description This function is similar to the date () function, the difference is that this function is returned with Greenwich Mean Time (Greenwich Mean Time, GMT) 1 2 Next last page

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