PHP time function
The function of the PHP time function is to return the current time and the Unix timestamp (Unix timestamp), which is the time from 00:00:00 on January 1, 1970, Greenwich Mean Time, to the current time, with seconds as the default Unit, the function of PHP time function is similar to mktime , but it is simpler. It can be used directly without setting parameters. It can be used with the date function to calculate some time difference, such as the date of next week or the date of next month. date. The time function is a built-in function of PHP and can be used without additional installation.
PHP time function syntax
PHP time function example
echo'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //Web page encoding
echo'current Unix timestamp:'.time().'< br>'; //Current Unix timestamp
$WeekSeconds=time()+(24*60*60*7); //24 hours x 60 minutes x 60 seconds x 7 days
echo'Today's date is:'.date('Ym -d').'<br>';
echo'Next week's date is:'.date('Ym-d',$WeekSeconds).'<br>';
?>
Today's date is: 2014-10-02
Next week's date is: 2014-10-09
Then the next line first outputs today’s date. This part uses the date function. Then we put $WeekSeconds into the parameter position of the date function, which is equivalent to the number of seconds in the next week calculated with time, and let the date function determine The actual date, the same technique can also be used to calculate the date of the next month! What needs attention is the number of days in the month, try it out!
Post a Comment
0 Comments