Home  >  Article  >  php教程  >  PHP 获取当前日期及格式化,php获取当前日期

PHP 获取当前日期及格式化,php获取当前日期

WBOY
WBOYOriginal
2016-06-13 09:26:47885browse

PHP 获取当前日期及格式化,php获取当前日期

date('Y-m-d H:i:s',time());

PHP怎获取当前时间

要设置时区,PHP默认的不是中国的时区,是格林威治时间。所以设置一下时区就可以搞定! date_default_timezone_set('Etc/GMT-8'); //这里设置了时区
echo date("Y-m-d H:i:s");
?>
 

问在PHP中取当前日期的时间戳(年-月-日)该怎写?

用date函数格式化一下就好了!
echo date("Y-m-d",time());
格式化字符串说明见图片~
希望我的回答对你有所帮助!呵呵~



 

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