当前位置:网站首页>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边栏推荐
- Binary search tree concept
- 数字电路基础(二)逻辑代数
- Database monitoring SQL execution
- 王爽汇编语言学习详细笔记一:基础知识
- Matplotlib绘图快速入门
- 《统计学》第八版贾俊平第四章总结及课后习题答案
- 使用 flask_whooshalchemyplus jieba实现flask的全局搜索
- Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
- Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
- [pointer] find the value of the largest element in the two-dimensional array
猜你喜欢

《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案

Library management system

1. Payment system

Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)

Binary search tree concept

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

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

Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?

Interview Essentials: what is the mysterious framework asking?

Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
随机推荐
Wang Shuang's detailed notes on assembly language learning I: basic knowledge
Functions: Finding Roots of equations
With 27K successful entry ByteDance, this "software testing interview notes" has benefited me for life
后台登录系统,JDBC连接数据库,做小案例练习
Lintcode logo queries the two nearest saplings
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
JDBC read this article is enough
关于超星脚本出现乱码问题
[pointer] find the value of the largest element in the two-dimensional array
The four connection methods of JDBC are directly coded
数据库多表链接的查询方式
刷视频的功夫,不如看看这些面试题你掌握了没有,慢慢积累月入过万不是梦。
Summary of thread implementation
Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
【指针】数组逆序重新存放后并输出
The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
使用 flask_whooshalchemyplus jieba实现flask的全局搜索
Why can swing implement a form program by inheriting the JFrame class?
《統計學》第八版賈俊平第七章知識點總結及課後習題答案