PHP:strtotime()总是返回01/01/1970 [英] PHP : strtotime() returns always 01/01/1970

查看:746
本文介绍了PHP:strtotime()总是返回01/01/1970的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用 strtotime 欧洲格式(dd / mm / yyyy)中显示日期,但是它总是返回01/01/1970。



这是我的codeline:

 <$ c $ ('d / m / Y',strtotime($ row ['DMT_DATE_DOCUMENT']))。< / h6>< / p>;回声< p> 

在我的数据库中,该字段是一个varchar,记录格式如 yyyy.mm。 dd



对于像 yyyy-mm-dd (varchar)这样的其他字段,我使用相同的代码行

感谢您的帮助。

解决方案

格式 yyyy-mm-dd 的作品,尝试用 -

$ $ p $ date('d / m / Y',strtotime(str_replace('。',' - ',' $行[ 'DMT_DATE_DOCUMENT'])));


I am trying to display dates in the European format (dd/mm/yyyy) with strtotime but it always returns 01/01/1970.

Here is my codeline :

echo "<p><h6>".date('d/m/Y', strtotime($row['DMT_DATE_DOCUMENT']))."</h6></p>";

In my database, the field is a varchar and records are formated like yyyy.mm.dd

I use the same codeline for another field that is formated like yyyy-mm-dd (varchar too) and it works fine.

Thanks for your help.

解决方案

Since the format yyyy-mm-dd works, try to replace . with -:

date('d/m/Y', strtotime(str_replace('.', '-', $row['DMT_DATE_DOCUMENT'])));

这篇关于PHP:strtotime()总是返回01/01/1970的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆