Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加每天定时执行的功能,附上一段定时运行的 #2

Closed
shanlanCoding opened this issue May 16, 2023 · 0 comments
Closed

Comments

@shanlanCoding
Copy link

shanlanCoding commented May 16, 2023

// 将时间格式化为JavaScript可以识别的格式
var dateString = "20230518010000";
var year = dateString.substring(0, 4);
var month = dateString.substring(4, 6);
var day = dateString.substring(6, 8);
var hour = dateString.substring(8, 10);
var minute = dateString.substring(10, 12);
var second = dateString.substring(12, 14);
var dateObject = new Date(year, month - 1, day, hour, minute, second);

// 计算延迟时间
var delay = dateObject.getTime() - new Date().getTime();

// 运行代码
setTimeout(function() {
  // 在这里运行您的代码
	botton_clicked();
}, delay);
@ljxi ljxi closed this as completed Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants