gpt4 book ai didi

javascript - 干 : How to simplify this duplicated code for date into a funciton?

转载 作者:行者123 更新时间:2023-11-30 08:20:24 27 4
gpt4 key购买 nike

<分区>

  • 是否可以将其塞入函数或数组?
  • 如何简化代码?

var yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
yesterday.setHours(03, 0, 0, 0);
var today = new Date();
today.setHours(03, 0, 0, 0);
var tomorrow1 = new Date();
tomorrow1.setDate(tomorrow1.getDate() + 1);
tomorrow1.setHours(03, 0, 0, 0);
var tomorrow2 = new Date();
tomorrow2.setDate(tomorrow2.getDate() + 2);
tomorrow2.setHours(03, 0, 0, 0);
var tomorrow3 = new Date();
tomorrow3.setDate(tomorrow3.getDate() + 3);
tomorrow3.setHours(03, 0, 0, 0);

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com