当前位置:网站首页>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边栏推荐
- 《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
- 《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
- 浙大版《C语言程序设计实验与习题指导(第3版)》题目集
- How to earn the first pot of gold in CSDN (we are all creators)
- 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
- {1,2,3,2,5}查重问题
- 线程的实现方式总结
- Mathematical modeling idea of 2022 central China Cup
- Interview Essentials: what is the mysterious framework asking?
- 《統計學》第八版賈俊平第七章知識點總結及課後習題答案
猜你喜欢

《统计学》第八版贾俊平第七章知识点总结及课后习题答案

Fundamentals of digital circuits (I) number system and code system

How to earn the first pot of gold in CSDN (we are all creators)

数字电路基础(二)逻辑代数
![Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)](/img/85/d6b196f22b60ad5003f73eb8d8a908.png)
Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)

Es full text index

数字电路基础(一)数制与码制

《统计学》第八版贾俊平第三章课后习题及答案总结

《统计学》第八版贾俊平第五章概率与概率分布

Circular queue (C language)
随机推荐
My first blog
JDBC 的四种连接方式 直接上代码
我的第一篇博客
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
王爽汇编语言学习详细笔记一:基础知识
JVM memory model concept
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
Wang Shuang's detailed learning notes of assembly language II: registers
Pointeurs: maximum, minimum et moyenne
Fundamentals of digital circuits (I) number system and code system
Load balancing ribbon of microservices
【指针】删除字符串s中的所有空格
Summary of thread implementation
Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
数据库多表链接的查询方式
Realize applet payment function with applet cloud development (including source code)
Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)
How to transform functional testing into automated testing?
The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?