1. Time zone settings
Method One: Set the Date.timezone=asia/hong_kong of the php.ini, so that the system default time is East 8 zone
Method Two: Use the function Date_default_timezone_set () to set the time zone to Date_default_timezone_set ("Asia/hong_kong")
2. Get the current timestamp
Use the time () function to return the current time and date directly, and the timestamp represents the number of seconds from January 1, 1970 0:0 0 seconds to the time of the program's Run
3. Get the current date and time
Use the date () function to return the current date. Date () has many parameters, such as using "D" to return the date of the current month 01 to 31
4. Resolve date and time to UNIX timestamp
Use the Maketime () function to generate the appropriate UNIX timestamp
Let's look at an example:
<?php
Date_default_timezone_set ("Asia/hong_kong");
$timefuture = Mktime (0,0,0,01,01,2016);
$timenow = time ();
$timecount = $timefuture-$timenow;
$day = Round ($timecount/86400);
echo Date ("Current time: Y year M D Day [L]h point I min s second", $timenow). " <br> ";
echo "is also available from January 1, 2016". $day. " Days. "." <br> ";
?>
The result of the operation is:
PHP date and time functions