Home  >  Article  >  Backend Development  >  php 日期格式转换疑问,望大神伸手

php 日期格式转换疑问,望大神伸手

WBOY
WBOYOriginal
2016-06-23 13:55:13951browse

MSSQL数据库里存的时间为:2013-06-28 00:00:00

PHP输入后格式为:06 28 2013 12:00AM

我用的方法是:date("Y-m-d日",strtotime($rs1['DJRQ']))     说明:$rs1['DJRQ'] = 06 28 2013 12:00AM

得到的结果是:1970-01-01

我想要的格式是:2013-6-28 或 2013-06-28 该如何解决呢?望高手指点。。


回复讨论(解决方案)

用时间戳转换

echo date('Y-m-d H:i:s', strtotime(preg_replace('/ /', '/', '06 28 2013 12:00AM', 2)));
2013-06-28 00:00:00

用时间戳转换


我转换过来是1970年01月01日的了。请问一下您可有别的方法?
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