search
Homephp教程php手册PHP 获取当前日期及格式化,php获取当前日期

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.