当前位置:网站首页>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边栏推荐
- Proceedingjoinpoint API use
- 四元数---基本概念(转载)
- The common methods of servlet context, session and request objects and the scope of storing data in servlet.
- 函数:用牛顿迭代法求方程的根
- C language learning summary (I) (under update)
- Software testing interview summary - common interview questions
- 数字电路基础(三)编码器和译码器
- [pointer] find the length of the string
- 关于超星脚本出现乱码问题
- [pointer] find the value of the largest element in the two-dimensional array
猜你喜欢
Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
Constants, variables, and operators of SystemVerilog usage
. Net6: develop modern 3D industrial software based on WPF (2)
后台登录系统,JDBC连接数据库,做小案例练习
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
Don't you even look at such a detailed and comprehensive written software test question?
5 minutes to master machine learning iris logical regression classification
《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
随机推荐
Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution
Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
【指针】数组逆序重新存放后并输出
[pointer] find the value of the largest element in the two-dimensional array
Function: find the root of the equation by Newton iterative method
函数:字符串反序存放
Always of SystemVerilog usage_ comb 、always_ iff
Binary search tree concept
Functions: Finding Roots of equations
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
Interview Essentials: what is the mysterious framework asking?
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
To brush the video, it's better to see if you have mastered these interview questions. Slowly accumulating a monthly income of more than 10000 is not a dream.
Intranet information collection of Intranet penetration (3)
JDBC read this article is enough
Function: calculates the number of uppercase letters in a string
Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)
Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
JDBC transactions, batch processing, and connection pooling (super detailed)