Home >Backend Development >PHP Tutorial >php time function, php function_PHP tutorial
There are so many time functions in PHP:
(1)date
Usage: date (format, [time]) ;
If there is no time parameter, the current time is used. The format is a string, in which the following characters have special meanings:
U is replaced with since a starting time (like January 1, 1970) seconds
Y is replaced with a 4-digit year number.
y is replaced with a 2-digit year number.
F is replaced with the full English name of the month.
M is replaced with the English abbreviation of the month.
m Replace with the number of months.
z Replace with the number of days since January 1 of the current year.
d Replace with the number of days.
l Replace with the full English name of the day of the week.
D Replace with the day of the week English abbreviation.
w is replaced with the day of the week (number).
H is replaced with the number of hours (24-hour format).
h is replaced with the number of hours (12-hour format).
i is replaced with minutes. Number.
s is replaced with seconds.
A is replaced with "AM" or "PM".
a is replaced with "am" or "pm".
S is replaced with ordinal suffix, for example :"st","nd","rd","th".
The function returns the replaced format string.
(2)getdate(time)
Returns a hash table, each subscript is:
"seconds" - - Seconds
"minutes" -- Fractions
"hours" -- Hours
"mday" -- Days
"mon" -- Months
"year" -- Year No.
"yday" -- the number of days since January 1st
"weekday" -- the day of the week, the full English name
"month" -- the month, the full English name
(3)gmdate
Similar to date, but first convert the time to Greenwich Mean Time.
(4)mktime
Usage:
mktime(hours, minutes, seconds, month, day, year); Return A time value that can be used in other functions.
(5)time()
Usage:
time(); Returns the number of seconds since midnight on January 1, 1970.
(6)microtime()
Usage:
microtime(); returns a string divided into two parts with spaces, the latter part is equivalent to time()
The return value of , the first part is the number of microseconds.
(7)checkdate
checkdate(month, day, year); returns logical true or logical false. If:
year is between 1900 and 32767 between 1900 and 32767;
The month is between 1 and 12;
The day is within the allowed number of days in the month (leap years are taken into account);
returns logical true.
(8) set_time_limit
Usage:
set_time_limit (number of seconds);
specifies that the program must end within the specified number of seconds from the time this sentence is run, and times out The program will exit with an error.
1· by:
All functions in PHP are from the UNIX era, that is, starting from January 1, 1970. The date is the number of seconds since this time. When a function calls the number of seconds since then, treat it as a timestamp.
Local time function
1. string date(string format,inieger timestamp)
This function returns a string representing the time, which is controlled by string format.
For example:
print(date("Y year m month d day");//Output the current year, month and day.
print(date("Y year m month d day",60*60*24*365*10);//Output January 1, 1980.
?>
Maybe you will ask, why is there no timestamp? If timestamp is empty, or does not write a time, it means that the current time timestamp is used.
represents the year control character: Y---four-digit year y---two-digit year
represents the control character of the month: m---month from 1-12 F---English month name M---abbreviated month name
represents the control symbol of day number: d---the day of the month with 0 in front j--the day number without 0 in front
represents the control symbol for the day of the week: l--English week D--Abbreviated week
represents the hour control character: h--hours from 1 to 12 H---hours from 0 to 23
indicates morning and afternoon control characters a ---am or pm A ---AM or PM
represents the minute control character: i---value 00-59
Additional z--date of the year
2. array getdate(integer timestamp)
This function returns a matrix.
For example:
$current_date=getdate();
print($current_date("hours"));
print($current_date("minutes");
print($current_date("seconds");
?>
Description:
Element Description
hours Hours in 24-hour format
mday Mid-month date
minutes minutes
mon month in numeric form
month Full name of month
seconds seconds
wday Day of the week as a number from 0 to 6
weekday The name of the day of the week
year year
0 timestamp is the number of seconds from January 1, 1970 to the present
yday The numeric date of the year
3. boolean checkdate(integer month,integer day,integer year)
This function checks whether the date is legal. For example:
if(checkdate(2,29,1980))
print("Date is valid!n");
?>
4. integer time()
This function obtains the current timestamp. For example:
print(time());//Output a large series of integers
?>
5. integer mktime(integer hour,integer minutes,integer seconds,integer month, integer day,integer year)
This function returns the timestamp of the given date, i.e. the number of seconds since January 1, 1970.
If a parameter is out of range, this function can also explain it, for example, 13th is January of the next year.
For example:
$currenthour=date("H");
print("After 50 hours:");
print(date("h:i A l F dS,Y",mktime($currenthour+50)));
print("
n");
?>
6. string microtime()
This function returns a string consisting of the current time in milliseconds + space + the number of seconds since 1970
print("start:microtime()
n");
for($index=0;$index<1000;$index++)
print("good!");
print("stop:microtime()
n");
?>
Also, I won’t talk about the Linwich Standard Time functions that are not commonly used! These are the commonly used ones.
-------------------------------------------------- ----------------------------------
2· By: the original poster
An example of a problem
$nowdate="1999-08-05" ;
$aa=getdate($nowdate);
$year=$aa['year'];
$month=$aa['mon'];
echo $year."";
echo $month;
Why you get:
1970
1
I want:
1999
8
How to solve it?
-------------------------------------------------- ----------------------------------
$nowdate="1999-08-05" ;
$aa=strtotime($nowdate);
$year=date("Y",$aa);
$month=date("n",$aa);
echo $year."";
echo $month;
-------------------------------------------------- ----------------------------------
3· by:
1, year-month-day
echo date('Y-m-j');
2007-02-6
echo date('y-n-j');
07-2-6
Capital Y represents the four-digit year, while lowercase y represents the two-digit year;
A lowercase m represents the number of the month (with a leading character), while a lowercase n represents the number of the month without a leading character.
echo date('Y-M-j');
2007-Feb-6
echo date('Y-m-d');
2007-02-06
Capital M represents the 3 abbreviated characters of the month, while lowercase m represents the number of the month (with leading 0);
There is no capital J, only lowercase j represents the date of the month, without the leading o; if the month needs to be preceded, use the lowercase d.
echo date('Y-M-j');
2007-Feb-6
echo date('Y-F-jS');
2007-February-6th
Capital M represents the 3 abbreviated characters of the month, while capital F represents the full English character of the month. (no lowercase f)
Capital S represents the suffix of the date, such as "st", "nd", "rd" and "th", depending on the date number.
Summary:
You can use uppercase Y or lowercase y to indicate the year;
The month can be represented by uppercase F, uppercase M, lowercase m and lowercase n (two ways to represent characters and numbers respectively);
can use lowercase d and lowercase j to represent the day, and uppercase S represents the suffix of the date.
2, hours: minutes: seconds
By default, the time displayed by PHP interpretation is "Greenwich Mean Time", which is 8 hours different from our local time.
echo date('g:i:s a');
5:56:57 am
echo date('h:i:s A');
05:56:57 AM
A lowercase g indicates a 12-hour format without leading 0s, while a lowercase h indicates a 12-hour format with leading 0s.
When using the 12-hour clock, you need to indicate morning and afternoon. Lowercase a represents lowercase "am" and "pm", and uppercase A represents uppercase "AM" and "PM".
echo date('G:i:s');
14:02:26
Capital G represents the hour in 24-hour format, but without leading; use capital H to represent the hour in 24-hour format with leading
Summary:
The letter g represents the hour without leading, and the letter h represents the hour with leading;
Lowercase g and h represent the 12-hour clock, and uppercase G and H represent the 24-hour clock.
3, leap year, week, day
echo date('L');
Whether this year is a leap year: 0
echo date('l');
Today is: Tuesday
echo date('D');
Today is: Tue
Capital L indicates whether this year is a leap year, Boolean value, returns 1 if true, otherwise 0;
The lowercase l represents the full English word for the day of the week (Tuesday);
Use a capital D to represent the 3-character abbreviation of the day of the week (Tue).
echo date('w');
Today's week: 2
echo date('W');
This week is week 06 of the year
The lowercase w represents the day of the week, and the number represents it
Capital W represents the number of weeks in the year
echo date('t');
This month is 28 days
echo date('z');
Today is the 36th day of the year
Lowercase t represents the number of days in the current month
Lowercase z indicates the day of the year today is
4, Others
echo date('T');
UTC
Capital T indicates the server’s time locale
echo date('I');
0
Capital I means to determine whether the current daylight saving time is, if true, return 1, otherwise 0
echo date('U');
1170769424
Capital U represents the total number of seconds from January 1, 1970 to the present, which is the UNIX timestamp of the Unix time epoch.
echo date('c');
2007-02-06T14:24:43+00:00
Lowercase c represents the ISO8601 date. The date format is YYYY-MM-DD. The letter T is used to separate the date and time. The time format is HH:MM:SS. The time zone is represented by the offset from Greenwich Mean Time (GMT). .
echo date('r');
Tue, 06 Feb 2007 14:25:52 +0000
Lowercase r indicates RFC822 date.
-------------------------------------------------- ----------------------------------
4· by:
Calculating the time difference in php is sometimes very troublesome!
However, I believe that in any language, as long as you master its regularity, you can find a way, and it will definitely turn decay into magic.
Date calculations are often performed at work. Here are some experiences gained from work. Write it down first so you don’t forget it later!
1. The first method is to calculate the time period difference (can be minutes, seconds, days)
$endtime="2004-09-09 18:10:00";
$d1=substr($endtime,17,2); //Seconds
$d2=substr($endtime,14,2); //minutes
$d3=substr($endtime,11,2); // time
$d4=substr($endtime,8,2); //Day
$d5=substr($endtime,5,2); //month
$d6=substr($endtime,0,4); //Year
echo $d1.'-'.$d2.'-'.$d3.'-'.$d5.'-'.$d4.'-'.$d6."n";
echo date("Y-m-d H:i:s")."n";
$now_T=mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")) ;
echo $now_T."n";
$now_S=mktime("$d3","$d2","$d1","$d5","$d4","$d6");
echo $now_S."n";
$end_TS=($now_S-$now_T)/60; //Calculate the remaining minutes
echo $end_TS;
?>
Note $startdate=mktime("0","0","0","1","1","2000");
//The obtained value is the total number of seconds from 1970-1-1 to the parameter time, then convert it into minutes/60 hours/3600 days/3600/24!
If the parameters in mktime() are default, it means using the current date.
2. If you have a database, it will be easy! If you have MSSQL, you can use triggers! Just use the function datediff() that specializes in calculating date differences!
If it is MYSQL, use the difference between the two date fields to calculate the calculation result and save it in another numeric field! Just call it when needed!
-------------------------------------------------- ----------------------------------
5· by: the original poster
The following collection date calculation methods:
A certain date plus a few days:
$tdate=date("Y-m-d");
$a=date( "Y-m-d", mktime(0,0,0,date("m"),date("d")+3,date("Y")));
$sql="select * from memo where username='$session_user_id'
and compid=$compid and telldate>='$tdate' and telldate<='$a'
order by id desc";
$ret=mysql_query($sql,$conn);
$a is today + three days!
$b=date( "Y-m-d", mktime(0,0,0,date("m"),date("d")-3,date("Y")));
$b is today - three days!
////
The date after a certain date plus n days
$days=abs((strtotime(date("Y-m-d"))-strtotime("xxxx-xx-xx"))/86400);
/////
-------------------------------------------------- ----------------------------------
6·Several methods of calculating time difference in php by :Owner
A simple example is to calculate the number of days to borrow a book. This requires PHP to calculate based on the date of each day. Let’s talk about several methods to implement this date calculation:
(1) If you have a database, it will be easy! If it is MSSQL, you can use triggers! Just use the function datediff() that specially calculates the date difference! If it is MYSQL, use the calculation result of the difference between two date fields. Save it in another numeric field! Just call it when you need it!
(2) If there is no database, you have to use PHP’s time and date function! The following is the main explanation:
Example: Calculate May 1998 Number of days from 3rd to 1999-6-5:
$startdate=mktime("0","0","0","5","3","1998");
$enddate=mktime("0","0","0","6","5","1999");
//The obtained value is from 1970-1-1 to The total number of seconds of parameter time: is an integer. Then
//The following code is much easier to compile:
$days=round(($enddate-$startdate)/3600/24) ;
//days is the number of days obtained;
If the parameter in mktime() is defaulted, it means using the current date, so that the number of days from the date of borrowing the book can be calculated.
-------------------------------------------------- ----------------------------------
7· By: the original poster
Calculating the time difference in php is sometimes very troublesome!
However, I believe that in any language, as long as you master its regularity, you can find a way, and it will definitely turn decay into magic.
Date calculations are often performed at work. Here are some experiences gained from work. Write it down first so you don’t forget it later!
1. The first method is to calculate the time period difference (can be minutes, seconds, days)
$endtime="2004-09-09 18:10:00";
$d1=substr($endtime,17,2); //Seconds
$d2=substr($endtime,14,2); //minutes
$d3=substr($endtime,11,2); // time
$d4=substr($endtime,8,2); //Day
$d5=substr($endtime,5,2); //month
$d6=substr($endtime,0,4); //Year
echo $d1.'-'.$d2.'-'.$d3.'-'.$d5.'-'.$d4.'-'.$d6."n";
echo date("Y-m-d H:i:s")."n";
$now_T=mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")) ;
echo $now_T."n";
$now_S=mktime("$d3","$d2","$d1","$d5","$d4","$d6");
echo $now_S."n";
$end_TS=($now_S-$now_T)/60; //Calculate the remaining minutes
echo $end_TS;
?>
Note $startdate=mktime("0","0","0","1","1","2000");
//The obtained value is the total number of seconds from 1970-1-1 to the parameter time, then convert it into minutes/60 hours/3600 days/3600/24!
If the parameters in mktime() are default, it means using the current date.
2. If you have a database, it will be easy! If you have MSSQL, you can use triggers! Just use the function datediff() that specializes in calculating date differences!
If it is MYSQL, use the difference between the two date fields to calculate the calculation result and save it in another numeric field! Just call it when needed!
-------------------------------------------------- ----------------------------------
8· by
date and time function library
-------------------------------------------------- ----------------------------------
This function library has a total of 12 functions
checkdate: Verify the correctness of the date.
date: Format the server's time.
strftime: Format the server's time locally.
getdate: Get time and date information.
gettimeofday: Get the current time.
gmdate: Get the time difference between the current time and GMT.
easter_date: Calculate Easter date.
easter_days: Calculate the number of days between Easter and March 21st.
mktime: Get UNIX timestamp.
gmmktime: Get the Greenwich Mean Time of a UNIX timestamp.
time: Get the UNIX timestamp of the current time.
microtime: Get the UNIX timestamp value of the current time in millionths of a second.
Function:checkdate()
-------------------------------------------------- ----------------------------------
Date and time function library
checkdate
Verify the date is correct.
Syntax: int checkdate(int month, int day, int year);
Return value: integer
Function type: Time and date
Content Description
Returns true if the date is valid, returns false if there is a problem with the date. This function can be used to check whether the date is valid. The valid range is as follows:
Year is 0 to 32767 years
Month is from January to December
The day changes with the month and leap year
Function:date()
-------------------------------------------------- ----------------------------------
Date and time function library
date
Format the server's time.
Syntax: string date(string format, int [timestamp]);
Return value: String
Function type: Time and date
Content Description
The string of the return value is determined by the configured format. If there is a timestamp value passed in, the timestamp will be formatted and returned; if there is no timestamp value passed in, the time of the current server will be formatted and returned. To convert dates to other language formats, the setlocale() and strftime() functions should be used. The options for string formatting are as follows:
a - "am" or "pm"
A - "AM" or "PM"
d - day, two digits, if there are less than two digits, add zeros in front; such as: "01" to "31"
D - day of the week, three English letters; such as: "Fri"
F - month, full English name; such as: "January"
h - hour in 12-hour format; e.g.: "01" to "12"
H - Hour in 24-hour format; e.g.: "00" to "23"
g - hour in 12-hour format, no zeros are added if there are less than two digits; such as: "1" to 12"
G - hour in 24-hour format, no zeros are added if there are less than two digits; such as: "0" to "23"
i - minutes; e.g.: "00" to "59"
j - day, two digits, if there are less than two digits, do not add zero; such as: "1" to "31"
l - day of the week, full English name; such as: "Friday"
m - month, two digits, if there are less than two digits, add zeros in front; such as: "01" to "12"
n - month, two digits, if there are less than two digits, no zero will be added; such as: "1" to "12"
M - month, three English letters; such as: "Jan"
s - seconds; e.g.: "00" to "59"
S - add an English ordinal number at the end of the word, two English letters; such as: "th", "nd"
t - the number of days in the specified month; such as: "28" to "31"
U - Total seconds
w - Numeric day 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 - day of the year; e.g.: "0" to "365"
Other characters not listed above will be listed directly.
Usage Example
Example 1:
print(date( "l dS of F Y h:i:s A" ));
print("July 1, 2000 is on a " . date("l", mktime(0,0,0,7,1,2000)));
?>
Example 2:
$tomorrow = mktime(0,0,0,date("m") ,date("d")+1,date("Y"));
$lastmonth = mktime(0,0,0,date("m")-1,date("d"), date("Y"));
$nextyear = mktime(0,0,0,date("m"), date("d", date("Y")+1);
?>
Function:strftime()
-------------------------------------------------- ----------------------------------
Date and time function library
strftime
Format the server's time locally.
Syntax: string strftime(string format, int [timestamp]);
Return value: String
Function type: Time and date
Content Description
The string of the return value is determined by the configured format. If there is a timestamp value passed in, the timestamp will be formatted and returned; if there is no timestamp value passed in, the time of the current server will be formatted locally and returned. The month or day of the week name changes depending on the locale configuration setlocale().
The returned string can be in the following format:
%a The abbreviation of the day of the week.
%A The full name of the day of the week.
%b The abbreviation of the month name.
%B The full name of the month.
%c is a string representing the local date and time better.
%d represents the day of the month as a number (range 00 to 31).
%H represents the hour as a 24-hour number (range 00 to 23).
%I represents the hour as a 12-hour number (range 01 to 12).
%j represents the day of the year as a number (range is 001 to 366).
%m Month number (ranging from 1 to 12).
%M minutes.
%p represents local time in 'AM' or 'PM'.
%S seconds.
%U The number represents the week number of the year, with the first week starting from the first Sunday.
%W The number represents the week number of the year, with the first week starting from the first Monday.
%w represents the day of the week as a number (0 is Sunday).
%x Date representation without time.
%X Time representation without date.
%y is a two-digit number representing the year (range from 00 to 99).
%Y is the complete numerical representation of the year, that is, four digits.
%Z time zone or name abbreviation.
%% % characters.
Usage Example
setlocale ("LC_TIME", "C");
print(strftime("%A in Finnish is "));
setlocale ("LC_TIME", "fi");
print(strftime("%A, in French "));
setlocale ("LC_TIME", "fr");
print(strftime("%A and in German "));
setlocale ("LC_TIME", "de");
print(strftime("%A.
"));
?>
Function: getdate()
-------------------------------------------------- ----------------------------------
Date and time function library
getdate
Get time and date information.
Syntax: array getdate(int timestamp);
Return value: Array
Function type: Time and date
Content description
The elements of the returned array include the following items:
"seconds" - seconds
"minutes" - minutes
"hours" - time
"mday" - the day of the month
"wday" - the day of the week
"mon" - month number
"year" - year, number
"yday" - the day of the year; such as: "299"
"weekday" - the full name of the day of the week; e.g.: "Friday"
"month" - the full name of the month; such as: "January"
---------------------------------- --------------------------------------------------
Function: gettimeofday()
---------------------------------------- ----------------------------------------
Date and time function library
gettimeofday
Get the current time.
Syntax: array gettimeofday(void)
Return value: Array
Function type: Time and date
Content description
The elements of the returned array include the following items:
"sec" - seconds
"usec" - one millionth of a second
"minuteswest" - Minutes in Greenwich Mean Time
"dsttime" - destination time zone
Function:gmdate()
-------------------------------------------------- ----------------------------------
Date and time function library
gmdate
Get the current time difference from GMT.
Syntax: string gmdate(string format, int timestamp);
Return value: String
Function type: Time and date
Content description
This function is similar to the date() function, except that this function returns the time difference from Greenwich Mean Time (GMT).
Usage Example
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 returned result is:
Jan 01 1998 00:00:00
Dec 31 1997 22:00:00
Function: easter_date()
-------------------------------------------------- ----------------------------------
Date and time function library
easter_date
Calculate Easter date.
Syntax: int easter_date(int [year]);
Return value: Integer
Function type: Time and date
Content description
If you enter a certain year, the Easter date of that year will be returned in UNIX timestamp format. If no year is input, the date of that year will be calculated. Note that the entered year must be between 1970 and 2037 AD, otherwise it cannot be calculated.
Usage Example
echo date("M-d-Y", easter_date(1999));
echo date("M-d-Y", easter_date(2000));
echo date("M-d-Y", easter_date(2001));
?>
The returned result is
Apr-04-1999
Apr-23-2000
Apr-15-2001
-------------------------------------------------- ----------------------------------
9· By: the original poster
Function: easter_days()
-------------------------------------------------- ----------------------------------
Date and time function library
easter_days
Calculate the number of days between Easter and March 21st.
Syntax: int easter_days(int [year]);
Return value: Integer
Function type: Time and date
Content Description
If you enter a certain year, the number of days between Easter and March 21 of that year will be calculated. If no year is entered, the current year will be used for calculation. This function can be used to replace the problem that easter_date() cannot calculate outside the range of 1970-2037.
Usage Example
echo easter_days(1999);
echo easter_days(1492);
echo easter_days(1913);
?>
The return result is:
14 (4/4)
32 (4/22)
2 (3/23)
----------------------------------------- ------------------------------------------
10· by: the original poster
Function:mktime()
--------------------------------------- ----------------------------------------
Date and time function library
mktime
Get UNIX timestamp.
Syntax: int mktime(int hour, int minute, int second, int month, int day, int year);
Return value: integer
Function type: Time and date
Content description
If you enter a time, a long integer of UNIX timestamp will be returned.
Usage Example
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) );
?>
11· by: the original poster
Function:gmmktime()
-------------------------------------------------- ----------------------------------
Date and time function library
gmmktime
Get the Greenwich Mean Time of a UNIX timestamp.
Syntax: int gmmktime(int hour, int minute, int second, int month, int day, int year);
Return value: integer
Function type: Time and date
Content Description
Enter a time and return a long integer of UNIX Greenwich timestamp.
-------------------------------------------------- ----------------------------------
12· by: the original poster
Function: time()
-------------------------------------------------- ----------------------------------
Date and time function library
time
Get the UNIX timestamp of the current time.
Syntax: int time(void);
Return value: integer
Function type: Time and date
Content description
Returns the stamp value of the current time.
-------------------------------------------------- ----------------------------------
13· by: the original poster
Function:microtime()
-------------------------------------------------- ----------------------------------
Date and time function library
microtime
Get the UNIX timestamp value of the current time in millionths of a second.
Syntax: string microtime(void);
Return value: String
Function type: Time and date
Content Description
Returns the millionth of a second stamp value of the current time. If the operating system does not provide the system call function of gettimeofday(), this function will also be invalid.
Use date("Y-m-d H:i:s", time())
date
to format the server's time.
Syntax: string date(string format, int [timestamp]);
Return value: String
Function type: Time and date
Content description
Return value ?The string is determined by the configured format. If there is a timestamp value passed in, the timestamp will be formatted and returned; if there is no timestamp value passed in, the time of the current server will be formatted and returned. To convert dates to other language formats, the setlocale() and strftime() functions should be used. The options for string formatting are as follows:
a - "am" or "pm"
A - "AM" or "PM"
d - day, two digits, if If there are less than two digits, add zeros in front; such as: "01" to "31"
D - day of the week, three English letters; such as: "Fri"
F - month, full English name; such as: "January "
h - hour in 12-hour format; such as: "01" to "12"
H - hour in 24-hour format; such as: "00" to "23"
g - 12-hour format Hours, do not add zeros if there are less than two digits; for example: "1" to 12"
G - hour in 24-hour format, do not add zeros if there are less than two digits; such as: "0" to "23"
i - minutes ; For example: "00" to "59"
j - Day, two digits, if there are less than two digits, do not add zero; For example: "1" to "31"
l - Day of the week, full English name ; For example: "Friday"
m - month, two digits, if less than two digits, add zeros in front; For example: "01" to "12"
n - month, two digits, if less than two digits The bits are not filled with zeros; such as: "1" to "12"
M - month, three English letters; such as: "Jan"
s - seconds; such as: "00" to "59"
S - add an English ordinal number at the end of the word, two English letters; such as: "th", "nd"
t - the number of days in the specified month; such as: "28" to "31"
U - the total number of seconds
w - Numeric day 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 - day of the year; such as: "0" to "365"
time() Get the current timestamp
strtotime() Convert to timestamp
date('Y-m-d H:i:s',time()) Convert timestamp to time