【js】js获取今日和昨日0点和23点59分59秒

news/2024/7/19 14:05:36 标签: js

1.今日0点和23时59分59秒

//方式1
const end = new Date(new Date().toLocaleDateString());
const start = new Date(new Date().toLocaleDateString());
start.setTime(start.getTime());
end.setTime(end.getTime() + 3600 * 1000 * 24 - 1000)
//方式2
const start  = new Date();
start .setHours(0);
start .setMinutes(0);
start .setSeconds(0);
start .setMilliseconds(0);

const end = new Date(start + 3600*1000*24 -1000)

1.昨日0点和23时59分59秒

 const today = new Date();
 today.setHours(0);
  today.setMinutes(0);
  today.setSeconds(0);
  today.setMilliseconds(0);
  const end = new Date(today - 1000);
  const start = new Date(today - 3600*1000*24);

http://www.niftyadmin.cn/n/903289.html

相关文章

【js】js校验

1.合法的uri /* 合法uri */ export function validateURL(textval) {const urlregex /^(https?|ftp):\/\/([a-zA-Z0-9.-](:[a-zA-Z0-9.&%$-])*)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]\.)*[…

【vue】el-select控件避免修改全局样式用属性popper-append-to-body

1.问题说明 1.默认el-select的popper-append-to-body属性是true,打开的el-select的气泡会追加到body中,导致局部样式无法修改 2.修改popper-append-to-body为true,气泡会追加到el-select控件上去,这样在el-select上加class属性便可以修改局部…

【vue】el-upload上传示例

1.前端代码 <template><div><el-uploadstyle"height: 100%"ref"upload"action"action":limit"limitNum":auto-upload"true":drag"true":accept"accept":show-file-list"false&quo…

【mysql】排序分页查询导致数据混乱问题

1.问题说明 1.根据创建时间排序&#xff0c;当创建时间大量重复时&#xff0c;分页查询会导致某条数据出现在不同分页中 select * from student order by create_time desc limit 10,10; select * from student order by create_time desc limit 20,10;2.问题解决 1.如果有id主…

【vue】avue-crud中filter-change过滤事件问题

1.问题说明 1.准备在filter表头过滤时做后台查询过滤&#xff0c;但无法获取是哪一列 2.avue-crud的filter-change事件中未封装column信息&#xff0c;这样在filter-change方法回调的时候&#xff0c;参数里只有默认的column信息&#xff0c;如果过滤的表头过多&#xff0c;无法…

【jvm】jvm基础学习篇-1

1.什么是JVM 1.Java Virtual Machine:java程序的运行环境&#xff08;java二进制字节码的运行环境&#xff09; 2.JVM的优点 1.一次编写&#xff0c;到处运行 2.自动内存管理&#xff0c;垃圾回收机制 3.数组下标越界检查 4.多态 3.JVM与JRE、JDK的比较 JVM JRE(JVM基础类库) J…

【idea】idea创建maven+spingboot项目

1.创建项目 2.选择Spring Initializr和jdk 3.填写Group和Artifact 4.选择Spring Web 5.完成

【java】springboot整合mybatis-plus报org.apache.ibatis.binding.BindingException: Invalid bound statement错误

1.解决方式 在pom文件中加入 <build><resources><resource><directory>src/main/resources</directory><filtering>true</filtering></resource><resource><directory>src/main/java</directory><incl…