Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何为一段时间编写一个条件?_Javascript_Date_Time_Momentjs - Fatal编程技术网

Javascript 如何为一段时间编写一个条件?

Javascript 如何为一段时间编写一个条件?,javascript,date,time,momentjs,Javascript,Date,Time,Momentjs,我试图得到一个有条件的what with the date of Tomory示例,让我知道what if is Tomory,并且是明天下午1点以上,所以做点什么吧 我与MomentJs合作,因此,如果您有此方面的解决方案可以帮助我,我将不胜感激。在MomentJs中,您可以在 const tomorrow = moment().add(1, 'days'); 如果你想得到明天下午1点那么 var tomorrow = moment('01:00 pm', "HH:mm a").add(1

我试图得到一个有条件的what with the date of Tomory示例,让我知道what if is Tomory,并且是明天下午1点以上,所以做点什么吧


我与MomentJs合作,因此,如果您有此方面的解决方案可以帮助我,我将不胜感激。

在MomentJs中,您可以在

const tomorrow  = moment().add(1, 'days');
如果你想得到明天下午1点那么

var tomorrow = moment('01:00 pm', "HH:mm a").add(1, 'days');
如果你想比较,那么

var tomorrow = moment('01:00 pm', "HH:mm a").add(1, 'days');

var current = moment();

if(current < tomorrow)
  console.log('true');
else
  console.log('false');
var明天=时刻('01:00 pm','HH:mm a')。添加(1,'days');
var电流=力矩();
如果(当前<明天)
console.log('true');
其他的
console.log('false');

在momentJS中,您可以在

const tomorrow  = moment().add(1, 'days');
如果你想得到明天下午1点那么

var tomorrow = moment('01:00 pm', "HH:mm a").add(1, 'days');
如果你想比较,那么

var tomorrow = moment('01:00 pm', "HH:mm a").add(1, 'days');

var current = moment();

if(current < tomorrow)
  console.log('true');
else
  console.log('false');
var明天=时刻('01:00 pm','HH:mm a')。添加(1,'days');
var电流=力矩();
如果(当前<明天)
console.log('true');
其他的
console.log('false');

要获取明天13:00的日期,您可以创建今天的日期,添加一天,然后将时间设置为13:00

然后,您可以使用比较运算符将其直接与其他日期进行比较
(但您需要将这两个日期转换为数字,以作为
=
==
进行比较)

例如

//如果d0在d1之前,则返回true,否则返回false
函数isBefore(d0,d1){
返回d0})
要获取明天13:00的日期,您可以创建今天的日期,添加一天,然后将时间设置为13:00

然后,您可以使用比较运算符将其直接与其他日期进行比较
(但您需要将这两个日期转换为数字,以作为
=
==
进行比较)

例如

//如果d0在d1之前,则返回true,否则返回false
函数isBefore(d0,d1){
返回d0
明天永远不会到来…;-)。你可以考虑为“今天”定一个日期,然后把时间定为13:00(<代码>日期。然后你可以看看他们是在之前还是之后。明天永远不会到来…;-)。你可以考虑为“今天”定一个日期,然后把时间定为13:00(<代码>日期。然后你可以看看他们是在之前还是之后。