我正在尝试使页面每3小时45分钟重新加载一次,无论用户何时加载页面,以便每个人每3小时45分钟重新加载页面,例如servertime我的服务器在多伦多和EST时区,所以EX id像是12:45 am 3:45 am 6:45 am 9:45 am 12:45 pm 3:45 Pm ...等等,建议还是不错的,这是我正在玩的代码
<script type="text/javascript">
setTimeout(function(){
//You can change this value based on the server location.
var offset = -5;
var now = new Date();
var utc = now.getTime() + (now.getTimezoneOffset() * 60000);
var serverTime = new Date(utc + (3600000*offset));
var hours = serverTime.getHours();
var minutes = serverTime.getMinutes();
if((hours % 3 == 0) && (minutes % 45 == 0)){
location.reload();
}
}, 30000);
</script>
但这似乎仅对某些用户有效,多数情况是-5时区内的用户,我需要同时刷新所有内容,无论他们在页面上停留了多长时间或放置在何处