Home > Backend Development > PHP Tutorial > 利用php获取服务器时间的实现代码_php技巧

利用php获取服务器时间的实现代码_php技巧

WBOY
Release: 2016-05-17 09:02:39
Original
917 people have browsed it

很多时候我们喜欢用js来获取日期和时间,但这仅仅是客户端的。
我们可以用php的date函数即可来获取服务器上的时间:

复制代码 代码如下:

//将时区设置为中国
date_default_timezone_set("PRC");
echo date("Y-m-d l H:i:s A");
//例输出:2010-03-06 Saturday 11:51:29 AM
?>

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template