在我的数据库字段中,使用 time();
函数保存日期和时间。
我想将其与日期格式为“20/02/2015”的给定日期进行比较
我的查询如下:
select view,optin,insertTime,isUnique from sg_page_report as PR where insertTime='20/02/2015'"
其中 insertTime
包含不同格式的日期,例如“1393587636”
如何解决这个问题?
最佳答案
WHERE FROM_UNIXTIME(insertTime)='2015-02-20'
或者你可以这样做
$ts=mktime(0,0,0,2,20,2015); // or
//$ts=strtotime('20/02/2015'); // inefficient
您的查询可以修改为如下所示
WHERE insertTime=$ts
关于php - 在 PHP 中将日期转换为时间格式输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30497467/