Home>Article>Backend Development> How to get the current time in php
The Date/Time function allows you to get the date and time from the server the PHP script is running on. You can use the Date/Time functions to format dates and times in different ways.
#Note:These functions depend on the local settings of the server. Remember to take daylight saving time and leap years into account when using these functions.
PHP Date/Time functions are an integral part of PHP core. No installation is required to use these functions. (Recommended learning:PHP programming from entry to proficiency)
Get the current date and time through the date() function in PHP
date(string format,int timestamp)
The date() function will return a string generated by the timestamp parameter according to the specified format. The timestamp parameter is optional. If omitted, the current time will be used. The format parameter can be the date and time output in the format specified by the developer.
"; echo "当前的日期为:".date("Y-m-d",mktime()).""; echo "当前的时间为:".date("H:i:s",mktime()); ?>
Use function date() to realize
Display format: year-month-day hour: minute: second
The above is the detailed content of How to get the current time in php. For more information, please follow other related articles on the PHP Chinese website!