Two common functions in PHP
rand (); Generate random numbers when there are no parameters in parentheses, the system generates random numbers at the current time as a seed
rand (1,10); Inside the parentheses is a range of generated random numbers, in the form of random numbers between 1~10, in PHP either do not write parameters, or write two parameters to form a valid range of values, can not write only one parameter or write two invalid parameters.
Time (); Time-Date function, where only time () is output, the words are displayed on the page is just a number, this number represents a timestamp, then we need to show that it is times rather than timestamps, we need to convert, here we use Date ();
The role of the date ("Y-m-d h:i:s", Time ())--date method is to convert a timestamp that we do not understand into a DateTime format that we can understand, and if it does not, the current date time is displayed.
Years:
Y--4-digit year with full indication: 1999 or 2003 years
y--2-digit year for example: 99 or 03 years
Month:
M--three-letter abbreviations for months such as: Jan or Dec
m-the number represents the month, with a leading 0 such as: January or December
Day:
D-the day of the week in three letters: Mon or Sun
D-the day ordinal of the month, with a leading 0 double digits such as: 01 or 31
When
H--24-hour format 1-24 hours
h--12-hour format 1-12 hours
Score of
I--the number of minutes with a leading 0 such as: 03 or 59 points
Seconds:
s--number of seconds with leading 0
Time ()--Timestamp
Attached: The display date and time is inconsistent with the current date time, mostly because the time zone is different, the simple way to modify the time zone is in the database in the PHP configuration file (php.ini), CTRL + F (Find) Date.timezone This sentence, the right hand side of the equal sign to etc/gmt-8,etc/gmt-8 represents the time zone of the East eight zone, you can also change to another time zone.
2016.6.2 Lonely Nightingale
php--generating random numbers and datetime