Home > Backend Development > PHP Tutorial > How to get current time in PHP

How to get current time in PHP

WBOY
Release: 2016-07-30 13:31:49
Original
1220 people have browsed it

Original address: http://zhidao.baidu.com/link?url=j325JdrGdItr_4uQgJkdqn4bKRubcrZ1nsh4Hm9mIQa4BSLqWwhOwHtQLOtIiOKa4GzqvhsTXs6ovoVU6wQGVa

Method one date function echo date('y-m-d h:i:s',time());/ /2010-08-29 11:25:26Method 2 time function$time = time();echo date("y-m-d",$time) //2010-08-29 Method three $_server['server_time']Method four strftimeecho strftime ("%hh%m %a %d %b" ,time());18h24 sunday 21 may Another problem is the time zone issue. The default time difference of the PHP environment is 8 hours different from Beijing time. If we want to get the correct time, we must set itAdd date_default_timezone_set('prc'); at the beginning of the PHP file Or date.timez/span> in php.ini. Remember to restart apache after modifying php.ini

The above introduces the method of obtaining the current time in PHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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