时刻比较 [英] Moment time comparison

查看:93
本文介绍了时刻比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var timeGraveyard = moment(itemT.ScreeningStart, 'LT');
var startTimeGraveyard = moment('12:00 AM', 'LT');
var endtimeGraveyard = moment('6:00 AM', 'LT');

if (timeGraveyard.isBetween(startTimeGraveyard, endtimeGraveyard)) {
    $('#lblGraveyard').text("Graveyard Schedule");
}





我的尝试:





What I have tried:

I want to limit the time between 12:00 AM and 6:00 AM

问题是它仍在执行if语句中的代码



timeGraveyard的样本输入:上午8:00

The problem is it still executing the code inside if statement

Sample input for timeGraveyard: 8:00 AM

推荐答案

('#lblGraveyard')。text(Graveyard Schedule );
}
('#lblGraveyard').text("Graveyard Schedule"); }





我的尝试:





What I have tried:

I want to limit the time between 12:00 AM and 6:00 AM

问题是它仍在执行if语句中的代码



timeGraveyard的样本输入:上午8:00

The problem is it still executing the code inside if statement

Sample input for timeGraveyard: 8:00 AM


我会尝试这样的话:

I'll try somehting like this:
moment(timeGraveyard).isBetween(startTimeGraveyard, endtimeGraveyard))





欲了解更多详情,请参阅:

介于两者之间 - momentjs.com [ ^ ]

javascript - moment.js - isBetween()方法不能始终如一地工作 - 堆栈溢出 [ ^ ]


这篇关于时刻比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆