php – 如何计算unix时间戳之间的时差?
发布时间:2020-12-13 17:51:38 所属栏目:PHP教程 来源:网络整理
导读:我使用time()在 PHP中创建时间戳; 我有$current_time和$purchase_time.如何确保purchase_time小于当前时间的24小时? 由于UNIX时间戳只是秒数,所以只需使用差异: $purchasedToday = $current_time - $purchase_time 24 * 60 * 60;if ($purchasedToday) { ec
我使用time()在
PHP中创建时间戳;
我有$current_time和$purchase_time.如何确保purchase_time小于当前时间的24小时?
由于UNIX时间戳只是秒数,所以只需使用差异:
$purchasedToday = $current_time - $purchase_time < 24 * 60 * 60; if ($purchasedToday) { echo 'You just bought the item'; } else { echo 'You bought the item some time ago'; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |