Chrome扩展程序:检测JavaScript中的新的一天(更改的日期)吗? [英] Chrome Extension: Detecting new day (day changed) in Javascript?

查看:60
本文介绍了Chrome扩展程序:检测JavaScript中的新的一天(更改的日期)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道没有新的一天(或小时/分钟)的事件监听器.但是在我的Chrome扩展程序中,我需要知道新的一天何时开始,这意味着我将不得不使用setInterval函数来确定一天的更改时间.但是,我不确定间隔值将使用什么:10秒或10分钟?我担心用完CPU和内存(恒定的setInterval调用),但是我仍然想几乎在新的一天开始时就知道.关于解决此问题的理想方法有什么想法?

I know there's not a event listener for a new day (or hour/minute, for that matter). But in my Chrome Extension, I need to know when a new day has started, and which means I'll have to use a setInterval function to find out when the day has changed. However, I'm not sure what to use for the interval value: 10 seconds, or 10 minutes? I'm worried about using up CPU & memory (constant setInterval calls), but I still want to know almost as soon as a new day starts. Any ideas as to what is the ideal way to handle this?

推荐答案

根据您想要的精确程度,唯一的方法是设置一个间隔.您可以将精度设置为任意值.1min 5min 10min

Depending how exact you want to be, the only way doing this is by setting an interval. You can set your precision to be whatever you want. 1min 5min 10min

这篇关于Chrome扩展程序:检测JavaScript中的新的一天(更改的日期)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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