我编写了一个 PHP 代码,在创建 5 分钟后终止会话。
我想在页面的角落显示一个计时器,向用户显示会话超时前的分钟数:秒数。有什么好的例子吗?
像这样的东西? http://keith-wood.name/countdown.html
你有一个简单的例子来展示如何使用它:
var newYear = new Date();
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1);
$('#defaultCountdown').countdown({until: newYear});
所以现在我们需要的是一个 UNIX 时间戳(会话结束的时间)。然后我们可以这样修改:
var endOfSession = new Date(youtitmestamp * 1000); // timestamp is in seconds and we need miliseconds
$('#defaultCountdown').countdown({until: endOfSession});
希望它有所帮助!