Javascript 如何及时获取今天的日期+00:00:00
我试着得到今天的日期+时间00:00:00 所以我是这样做的:Javascript 如何及时获取今天的日期+00:00:00,javascript,momentjs,Javascript,Momentjs,我试着得到今天的日期+时间00:00:00 所以我是这样做的: const startDate = DateTime.fromISO(params.start) .startOf('day') .toFormat('yyyy-LL-dd HH:mm:ss'); 但如果我使用console.log: 我得到一个错误: 折线图.service.ts:22 startData无效日期时间 那么我要改变什么呢 所以我想在这里使用
const startDate = DateTime.fromISO(params.start)
.startOf('day')
.toFormat('yyyy-LL-dd HH:mm:ss');
但如果我使用console.log:
我得到一个错误:
折线图.service.ts:22 startData无效日期时间
那么我要改变什么呢
所以我想在这里使用它:
return this.sensorNodeService.cameraDataInInterval(
16,
startDate,
'2021-01-20 23:59:59',
'1'
);
设c=新日期;//以当前时间为准
c、 setHours0;
c、 setMinutes0;
c、 设置秒0;
//在时区的00:00:00打印当前日期
//格式为2020-12-02 12:10:12
console.logc.toISOString.replace/T/,''.replace/\..+/ 以下是您如何做到这一点的方法,包括日期/时间;还是时间!: 函数日期时间{ return new Date.toLocaleStringen-US,{year:'numeric',month:'numeric',day:'numeric',hour:numeric,minute:numeric,second:numeric,hour12:true}; } console.logDateTime; 功能时间{ 返回新日期。ToLocalStringen-US{ 小时:数字, 分钟:数字, 第二:数字, 12小时:对 }; } 控制台日志时间 var todaydate=新日期; var datetime=todaydate.getDate+/+ todaydate.getMonth+1+/+ todaydate.getFullYear++ +todaydate.getHours+:+ todaydate.getMinutes+:+ todaydate.getSeconds;
console.logdatetime;什么是DateTime?@evolutionxbox似乎是,但我们不能确定我认为这不是OP想要的…解释一下。。。这是DateTime。是的,但是OP的DateTime可能来自一个库,并要求帮助他们做了什么错误,而不是如何实现这样的事情…这是一个不同的库,它是luxon.js。快速搜索会在几秒钟内建议。这里的所有答案都提供了JS中的本机日期时间功能。他们做错的是没有利用它哦,b,但它是由t和z组成的。这不是我的意思抱歉,但什么是t和z?你是说时区吗?我用的是角度。所以这必须是格式:'2021-01-20 23:59:59'好的-您可以使用。我将编辑答案。但它必须以:00:00:00开始
return this.sensorNodeService.cameraDataInInterval(
16,
startDate,
'2021-01-20 23:59:59',
'1'
);