Home >Backend Development >PHP Tutorial >php时间解决方法

php时间解决方法

WBOY
WBOYOriginal
2016-06-13 12:13:44920browse

php时间
如何把一个日期$time=date("Y-m-d-H-i")的数据提取出前三位?
------解决思路----------------------

本帖最后由 fdipzone 于 2015-01-15 16:50:09 编辑
<br />$time=date("Y-m-d-H-i");<br />echo preg_replace('/(\d+)-(\d+)-(\d+)-(\d+)-(\d+)/', '${1}年${2}月${3}日', $time); // 2015-01-15<br />
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