当前位置:网站首页>How to use Moment. JS to check whether the current time is between 2 times
How to use Moment. JS to check whether the current time is between 2 times
2022-07-06 14:48:00 【javail】
problem :
Say the current time is 09:34:00
( hh:mm:ss
), and I have two other times in two variables: Suppose the current time is 09:34:00
( hh:mm:ss
), I have two other times in two variables :
var beforeTime = '08:34:00', afterTime = '10:34:00';
How do I use Moment.JS to check whether the current time is between beforeTime
and afterTime
? How to use Moment.JS Check whether the current time is beforeTime
and afterTime
Between ?
I've seen isBetween()
, and I've tried to use it like: I have seen isBetween()
, I've tried to use it like this :
moment().format('hh:mm:ss').isBetween('08:27:00', '10:27:00')
but that doesn't work because as soon as I format the first (current time) moment into a string, it's no longer a moment object. But it doesn't work , Because once I will be the first ( current time ) The time is formatted as a string , It is no longer an object of time .I've also tried using: I've also tried to use :
moment('10:34:00', 'hh:mm:ss').isAfter(moment().format('hh:mm:ss')) && moment('08:34:00', 'hh:mm:ss').isBefore(moment().format('hh:mm:ss'))
but I get false
, because again when I format the current time, it's no longer a moment. But I got false
, Because when I format the current time again , It is no longer a moment .
How do I get this to work? How can I make this work ?
Solution :
Reference resources : https://stackoom.com/en/question/2RsV5边栏推荐
- Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
- Library management system
- Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
- Keil5-MDK的格式化代码工具及添加快捷方式
- Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
- Bing Dwen Dwen official NFT blind box will be sold for about 626 yuan each; JD home programmer was sentenced for deleting the library and running away; Laravel 9 officially released | Sifu weekly
- Binary search tree concept
- 指针:最大值、最小值和平均值
- Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution
- Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)
猜你喜欢
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
数字电路基础(一)数制与码制
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
5 minutes to master machine learning iris logical regression classification
JDBC read this article is enough
Library management system
《统计学》第八版贾俊平第二章课后习题及答案总结
Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
JVM memory model concept
Captcha killer verification code identification plug-in
随机推荐
【指针】数组逆序重新存放后并输出
【指针】查找最大的字符串
Function: find 1-1/2+1/3-1/4+1/5-1/6+1/7-... +1/n
Database monitoring SQL execution
[pointer] find the largest string
Flash implements forced login
“Hello IC World”
Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
1. Payment system
《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
Constants, variables, and operators of SystemVerilog usage
5分钟掌握机器学习鸢尾花逻辑回归分类
Es full text index
Interview Essentials: what is the mysterious framework asking?
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
Statistics 8th Edition Jia Junping Chapter 1 after class exercises and answers summary
Using flask_ Whooshalchemyplus Jieba realizes global search of flask
Library management system
《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案
JDBC read this article is enough