Php最后登录时间和当前登录时间差...对或错? [英] Php last login time and current login time difference... Right or wrong?

查看:166
本文介绍了Php最后登录时间和当前登录时间差...对或错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是:

如何显示上次登录时间(年,月,周,日,时间,秒)..我试过但错误输出

上次登录时间:2012-05-11 10:16:51当前时间是:2012-05-11 10:35:51

Last login is: 2012-05-11 10:16:51 Current Time is: 2012-05-11 10:35:51

$diff_seconds = strtotime($current_time) - strtotime($lastLoginTime); 

是这个正确的 $ diff_seconds -1336724211

推荐答案

我无法重现。我做了

$time1 = '2012-05-11 10:16:51';
$time2 = '2012-05-11 10:35:51';

echo strtotime($time1) - strtotime($time2);
echo '<br>';
echo strtotime($time2) - strtotime($time1);

我有

-1140

1140

看起来很合法。请显示您的代码。也许你没有一个字符串,它与你的年数字有一些奇怪的计算?

Looks legit. Please show your code. Maybe you did not have a string and it did some weird calculation with your year digits?

这篇关于Php最后登录时间和当前登录时间差...对或错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆