gpt4 book ai didi

php - 如何识别用户更新后的时间?

转载 作者:行者123 更新时间:2023-11-29 04:52:34 24 4
gpt4 key购买 nike

如何确定用户在我的 MySQL 数据库中更新他的帐户后耗时?我的 MySQL 表中有一个时间戳(用于存储用户更新时间),那么现在如何使用 PHP 识别自上次用户更新以来耗时?

例如:

User last update time: 2012-04-08 00:20:00;

Now: 2012-04-08 00:40:00;

Time passed since last update: 20 (minutes) ← I need this using PHP

最佳答案

如果你有数据在

$last_update_time = '2012-04-08 00:20:00';
$now = time(); //this gets you the seconds since epoch

你可以做到

$last_update_since_epoch = strtotime($last_update_time); //this converts the string to the seconds since epoch

aand... 现在,因为你在这两个变量上都有秒数

$seconds_passed = $now - $last_update_since_epoch;

现在,您可以执行 $seconds_passed/60 来获取自上次更新以来经过的分钟数。

希望这有帮助;)

关于php - 如何识别用户更新后的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10060271/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com