我在MySQL中看到了在UNIX时代和日期时间之间来回转换的说明--这并不太困难(from_unixtime从一个时代转换到一个日期时间,unix_timestamp来获得当前的日期时间)。
不幸的是,我把服务器上所有的时间戳都保存成了双份--当我试图把双份投到时间戳上时,我失败了。
select
from_unixtime(cast('1416355920908' as datetime)),
from_unixtime(cast(1416355920908 as datetime)),
from_unixtime(unix_timestamp());
我把“生日”作为时间戳(整数)存储在Sphinx搜索引擎中。
(例如)
User DOB is "12-01-1960" (Age is 55)
Sphinx side: 3980298496 (MySQL handle this from DB to Sphinx)
在PHP方面,出于搜索目的,我想计算时间戳,如下所示,但它给出了负值,因为如果日期小于1970年1月1日,PHP就会给出负值
Carbon::now()->subYears('55')->timestamp = -288316800
如何制作一个积极的时间戳?这样我就可以在PHP中进行
我试图将mysql中的时间戳表单转换为日期,并在此日期之前订购。
$query = mysql_query("SELECT *,DATE_FORMAT(banfrom ,'%d/%c/%Y') as time FROM ab_list ORDER BY time DESC LIMIT 0,50");
它没有显示我试图这样做的日期:
while($info = mysql_fetch_array($query))
{
echo $info['time'];
}
在这个日期之前,我怎样才能在回声中显示日期?
谢谢各位
我一直在使用setTimeStamp以以下方式将Unix时间戳转换为日期时间:
$startHireConverted = strtotime($startHire); // converts start hire to time
$endHireConverted = strtotime($endHire); // converts end hire to time
$startdt = new DateTime();
$startdt->setTimeStamp($startHireConverted);
$mysql_startdate = $startdt->format