php取得当前时间函数文章提供了php的几种获取当前时间的函数,date,time等哦,同时告诉我如何解决时区问题哦。
php教程取得当前时间函数
文章提供了php的几种获取当前时间的函数,date,time等哦,同时告诉我如何解决时区问题哦。
方法一date函数
echo date(‘y-m-d h:i:s’,time());
//2010-08-29 11:25:26
方法二 time函数
$time = time();
echo date("y-m-d",$time) //2010-08-29
方法三 $_server['server_time']
方法四 strftime
echo strftime ("%hh%m %a %d %b" ,time());
18h24 sunday 21 may
还有一个问题就是时区问题,php环境默认时差与北京时间相差8小时,我们要想获取正确的时间就必须设置
在php文件开始处 加上date_default_timezone_set('prc');
或在php.ini里面 date.timezone=prc;嗾。
记得修改了php.ini要重起apache
本站原创教程转载注明来源 http://www.bkjia.com/phper/php.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
