Simple sample code for php date functions
- A small example of a php date function -bbs.it-home.org
- Echo time (); // The number of seconds (timestamp) from 00:00:00, January 1, January 1, 1970 to the current time)
- Echo"
";
- Echo mktime (,); // output the timestamp of the specified time (hour, minute, second, month, day, and year)
- Echo mktime (,); // The time exceeds the threshold and is estimated to be greater.
- Echo"
# ------------ Strtotime function -----------------# ";
- Echo strtotime ("20:20:29"); // converts a specified time date to a timestamp, indicating a connection between a month, a day, and a year.
- // Only-or/can be used. the connection time and minute-second can only be:
- Echo strtotime ("2009/10/12 20/20/29"); // unable to output
Echo" # ------------- Getdate and date functions ---------------# ";
- Print_r (getdate (); // returns the date array under the current timestamp. the default value is the current timestamp.
- $ Arrtime = getdate (strtotime ("2009-10-12 20:20:29"); // returns an array with the specified date and time stamp.
- Echo"
";
- Echo $ arrtime ["minutes"];
- Echo"
";
- Echo date ("Y" m "d H" I "s A"); // enter the date format of the specified date and time stamp. the default value is the current time stamp.
- Echo"
";
- Echo date ("Y, m, d, H, I minute, s second, A", strtotime ("20:20:29 "));
- ?>
-
|