PHP Time and Date function

Source: Internet
Author: User
Tags current time echo date getdate string format time and date

SetLocale () mktime ()
GetDate Get time and date information.
Syntax: array getdate (int timestamp);
return value: Array
Function Type: time date
Content description The elements that return an array include the following items:
"Seconds"-seconds
"Minutes"-min
"Hours"-when
"Mday"-Day of the month
"Wday"-the number of days of the week
"Mon"-month numbers
"Year"-years, numbers
"Yday"-Number of days of the year; such as: "299"
"Weekday"-full name of the week; such as: "Friday"
"Month"-month full name; such as: "January"
Gettimeofday to get the current time.
Syntax: array gettimeofday (void);
return value: Array
Function Type: time date
Content description The elements that return an array include the following items:
"SEC"-sec
"USec"-one out of 10,000 seconds
"Minuteswest"-The Point of GMT
"Dsttime"-time zone for the purpose
Gmdate gets the current time after the difference with GMT.
Syntax: string gmdate (string format, int timestamp);
return value: String
Function Type: time date
Content description This function is similar to the date () function, and this function returns the time after the GMT (Greenwich Mean Time, GMT) difference
Usage examples
<?php
echo Date ("M D Y h:i:s", Mktime (0,0,0,1,1,1998));
Echo gmdate ("M D Y h:i:s", Mktime (0,0,0,1,1,1998));
?>
If the machine executing this example is in Finland (Finland, GMT +0200), the result returned is:
01 1998 00:00:00
Dec 31 1997 22:00:00
Reference date () Mktime () Gmmktime ()
Easter_date calculates the Easter date.
Syntax: int easter_date (int [year]);
return value: Integer
Function Type: time date
Description: If you enter a year, the date of the year is returned in the form of a UNIX timestamp, and if no year is entered. Value? Note that the entered year must be between 1970-2037 and will not be counted.
Usage examples
?
echo Date ("M-d-y", Easter_date (1999));
echo Date ("M-d-y", Easter_date (2000));
echo Date ("M-d-y", Easter_date (2001));
?>
Returns the result to
apr-04-1999
apr-23-2000
apr-15-2001
Easter_days calculates the number of dates between Easter and March 21.
Syntax: int easter_days (int [year]);
return value: Integer
Function Type: time date
Content Description Enter a year to calculate the number of dates between Easter and March 21 of the year and, if no year is entered, in the current year. This function can be used to replace the easter_date () 1970-2037 years beyond the scope of the calculation of the problem.
Usage examples
?
Echo Easter_days (1999);
echo easter_days (1492);
Echo Easter_days (1913);
?>
The result returned is:
14 (4/4)
32 (4/22)
2 (3/23)
Reference Easter_date ()
Mktime Gets the UNIX time stamp.
Syntax: int mktime (int hour, int minute, int second, int month, int day, int year);
return value: Integer
Function Type: time date
Description: Enter a time to return a long integer for the UNIX time stamp.
Usage examples
?
echo Date ("M-d-y", Mktime (0,0,0,12,32,1997));
echo Date ("M-d-y", Mktime (0,0,0,13,1,1997));
echo Date ("M-d-y", Mktime (0,0,0,1,1,1998));
?>
Reference date () time ()
Gmmktime obtains the UNIX time stamp GMT.
Syntax: int gmmktime (int hour, int minute, int second, int month, int day, int year);
return value: Integer
Function Type: time date
Description: Enter a time that returns the long integer of the UNIX GMT stamp.
Time gets the UNIX timestamp for the current time.
Syntax: int time (void);
return value: Integer
Function Type: time date
The content description returns the stamp value for the current time.
Reference date ()
Microtime the one out of 10,000-second value of the UNIX time stamp that obtained the current time.
Syntax: string microtime (void);
return value: String
Function Type: time date
The content description returns the one out of 10,000-second stamp value of the current time. This function is also invalid if the operating system does not provide a gettimeofday () call function.

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.