Home  >  Article  >  Backend Development  >  正则表达式修改字符串为时间格式

正则表达式修改字符串为时间格式

WBOY
WBOYOriginal
2016-06-06 20:15:51944browse

20160313t212947

改成 2016-03-13 21:29:47

正则表达式修改字符串为时间格式
有没有正则表达式简单一点搞定?

回复内容:

20160313t212947

改成 2016-03-13 21:29:47

正则表达式修改字符串为时间格式
有没有正则表达式简单一点搞定?

为什么用这种格式的时间?

使用 strtotime 函数

<code>$timestamp = strtotime('20160313t212947');
echo date('Y-m-d H-i-s', $timestamp);</code>
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