Home  >  Article  >  Backend Development  >  Implementation code for obtaining server time using PHP_PHP tutorial

Implementation code for obtaining server time using PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:07:58696browse

Many times we like to use js to get the date and time, but this is only on the client side.
We can use PHP’s date function to get the time on the server:

Copy the code The code is as follows:

//Set the time zone to China
date_default_timezone_set("PRC");
echo date("Y-m-d l H:i:s A");
//Example output :2010-03-06 Saturday 11:51:29 AM
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327502.htmlTechArticleMany times we like to use js to get the date and time, but this is only on the client side. We can use PHP's date function to get the time on the server: Copy the code The code is as follows...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn