php tutorial date format details
All functions in php are unix epochs, 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 counted from this time, it is treated as a times **** p timestamp.
Local time function
1. string date (string format, inieger times **** p)
This function returns a string representing time, controlled by string format.
Such as:
<?
print (date ("y-year m-day"); // Output current, year, month, day.
print (date ("y-year m-day", 60 * 60 * 24 * 365 * 10); // Output January 1, 1980.
?>
Maybe you will ask, how no times **** p? If times **** p is empty, or do not write, said the use of the current time times **** p.
Represents the year of the control character: y --- four years y --- two years that the control symbol of the month: m --- month from 1-12 f --- English month name m --- short The name of the month that the control number of the day number: d --- month in front of the 0 date j - no day before the 0 that the week of the control characters: l - English week d - abbreviated week said hours Control characters: h - from 1 to 12 hours h --- from 0 to 23 hours that morning and afternoon control symbol a --- am or pm a --- am or pm
Said control minute: i --- value 00-59
Indicates how many days of the year: z - how many days of the year
Array getdate (integer times **** p)
This function returns a matrix.
Such as:
<?
$ current_date = getdate ();
print ($ current_date ("hours"));
print ($ current_date ("minutes");
print ($ current_date ("seconds");
?>
Description:
Element Description
hours 24 hours format
mday month in the date
minutes minutes
mon Number of months in the form of numbers
month month full name
seconds seconds
wday Number of days from 0 to 6 in the form of numbers
the name of weekday
year year
0 The timestamp is the number of seconds from January 1, 1970 to the present
yday The year in digital form
Boolean checkdate (integer month, integer day, integer year)
This function checks if the date is valid.
<?
if (checkdate (2,29,1980))
print ("date is legal! n");
?>
Integer time ()
This function gets the current timestamp. For example:
<?
print (time ()); // Output a long list of integers
?>
Integer mktime (integer hour, integer minutes, integer seconds, integer month, integer day, integer year)
The function returns the timestamp given the date, which is the number of seconds from January 1, 1970 to the present.
If a parameter out of range, the function can also explain it, such as the month of January is the second year in January.
Such as:
<?
$ currenthour = date ("h");
print ("50 hours later:");
print (date ("h: ialf ds, y", mktime ($ currenthour + 50)));
print ("<br> n");
?>
6. string microtime ()
The function returns a string of milliseconds from the current time + space + number of seconds since 1970
<?
print ("start: microtime () <br> n");
for ($ index = 0; $ index <1000; $ index ++)
print ("good!");
print ("stop: microtime () <br> n");
?>