Home  >  Article  >  Backend Development  >  php修改时间格式的代码_php技巧

php修改时间格式的代码_php技巧

WBOY
WBOYOriginal
2016-05-17 09:19:01878browse

修改时间格式:
date("Y-m-d",strtotime($list['pubdate']));
学习解释:将时间放入strtotime为时间戳后用date()转化格式.下面写了两个函数的

PHP strtotime() 函数
strtotime() 函数将任何英文文本的日期时间描述解析为 Unix 时间戳。

语法
strtotime(time,now)参数 描述
time 规定要解析的时间字符串。
now 用来计算返回值的时间戳。如果省略该参数,则使用当前时间。


PHP Date() 函数可把时间戳格式化为可读性更好的日期和时间。

语法
date(format,timestamp)参数 描述
format 必需。规定时间戳的格式。
timestamp 可选。规定时间戳。默认是当前的日期和时间。

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