【发布时间】:2016-11-25 12:16:51
【问题描述】:
我有数据库。我将我的价值保存在 1480079589 时间。 我想测量当前时间和我保存的数据库时间之间的时间。
我不知道,因为我不懂时间逻辑。 1480079589是几点?
【问题讨论】:
标签: php
我有数据库。我将我的价值保存在 1480079589 时间。 我想测量当前时间和我保存的数据库时间之间的时间。
我不知道,因为我不懂时间逻辑。 1480079589是几点?
【问题讨论】:
标签: php
计算时差
SELECT timestamp AS 'thisisit'
FROM table
WHERE TIMESTAMPDIFF(MINUTE, timestamp, NOW()) <= 15;
这是timestamp。
使用 PHP 的 date() 函数。
例子:
echo date('m/d/Y', 1480079589);
简单地说,Unix时间戳是一种跟踪时间的方法 总秒数。这个计数从 1 月 1 日的 Unix 纪元开始, 1970 年在 UTC。因此,Unix 时间戳只是 特定日期和 Unix 纪元之间的秒数。它也应该 需要指出的是,这个时间点在技术上不会改变 无论您在地球上的哪个位置。这对 用于动态跟踪和分类过时信息的计算机系统 以及在线和客户端的分布式应用程序。原因 为什么许多网站管理员使用 Unix 时间戳是因为它们可以 一次代表所有时区。
请参阅此以获取更多信息: http://php.net/manual/en/datetime.settimestamp.php
【讨论】:
1480079589 是时间戳,即距离时间界标 (1970-01-01 00:00:00) 的秒数。这意味着距离地标 1480079589 秒。
日期('Y-m-d H:i:s', 1480079589);
这将以友好的方式打印日期供您查看
【讨论】:
那是 UNIX 时间。
The unix time stamp is a way to track time as a running total of seconds.
This count starts at the Unix Epoch on January 1st, 1970 at UTC.
Therefore, the unix time stamp is merely the number of seconds between a particular date and the Unix Epoch.
It should also be pointed out (thanks to the comments from visitors to this site) that this point in time technically does not change no matter where you are located on the globe. This is very useful to computer systems for tracking and sorting dated information in dynamic and distributed applications both online and client side.
要获得时差,试试这个:
<?php
$databaseTime = 1480079589; // Time from DataBase
print(time() - $databaseTime); // How much second
【讨论】:
时间格式为自 1970 年 1 月 1 日午夜以来的秒数。也称为 Unix 时间或时间戳。 你会得到这是带有 time() 函数的 php。要测量经过的时间,您只需比较两个时间戳并获取其间的秒数。 您可以使用
将时间戳转换为人类可读的格式gmdate("M d Y H:i:s", $unixTimestamp);
date("M d Y H:i:s", $unixTimestamp);
【讨论】:
我用
DATE_SUB(NOW(),INTERVAL 5 MINUTE)
在 sql 查询中。我的问题就解决了。
【讨论】: