当前位置:网站首页>In JS, the regular expression verifies the hour and minute, and converts the input string to the corresponding hour and minute
In JS, the regular expression verifies the hour and minute, and converts the input string to the corresponding hour and minute
2022-06-24 07:12:00 【For notes】
List of articles
1、 Preliminary knowledge
splict() Method

Date() Related methods


setHours() Usage of

2、 stay js Code snippet in
// Verify hours and minutes
var reDateTime = /^(?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]$/;
var isDateTime = reDateTime.test('18:00');
console.log(isDateTime)
var startTime = "09:00";
var endTime = "18:00";
var t1 = new Date();
let start = startTime.split(":") ;
t1.setHours(start[0],start[1],0);
console.log(" Starting time :"+t1)
var t2 = new Date();
let end = endTime.split(":");
t2.setHours(end[0],end[1],0);
console.log(" End time :"+t2)
if(t1.getTime() > t2.getTime()){
console.log(" error ");
}else if(t1.getTime() == t2.getTime()){
console.log(" equal ")
}else{
console.log(" correct ")
}
3、 test result

边栏推荐
- High energy ahead: Figure 18 shows you how to use the waterfall chart to visually reflect data changes
- System design: partition or data partition
- Accelerate large-scale data analysis based on Apache iceberg through data organization optimization
- Mysql开启BINLOG
- Kaseya of the United States was attacked by hackers, and 1500 downstream enterprises were damaged. How can small and medium-sized enterprises prevent extortion virus?
- 原神方石机关解密
- JSON online parsing and the structure of JSON
- JVM调试工具-jps
- Are internal consultants and external consultants in SAP implementation projects difficult or successful? [English version]
- How to make a website? What should I pay attention to when making a website?
猜你喜欢

Typora charges? Build vs Code markdown writing environment

puzzle(019.1)Hook、Gear

The data synchronization tool dataX has officially supported reading and writing tdengine

JVM调试工具-Arthas

Application configuration management, basic principle analysis

Outils de débogage JVM - Arthas

【小技巧】使用matlab的深度学习工具箱deepNetworkDesigner快速设计

Computing power and intelligence of robot fog

【帧率倍频】基于FPGA的视频帧率倍频系统verilog开发实现

华为云图引擎服务
随机推荐
Research on redis High Availability Mechanism
Smart space 𞓜 visualization of operation of digital twin cargo spacecraft
How do I check the IP address? What is an IP address
Coding helps promote the internationalization of Tencent games
智能视觉组A4纸识别样例
FreeRTOS MPU makes the system more robust!
Internet cafe management system and database
雲監控系統 HertzBeat v1.1.0 發布,一條命令開啟監控之旅!
Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.
Nine unique skills of Huawei cloud low latency Technology
【问题解决】虚拟机配置静态ip
[Yugong series] June 2022 asp Basic introduction and use of cellreport reporting tool under net core
0 foundation a literature club low code development member management applet (5)
JVM调试工具-jmap
Interpreting top-level design of AI robot industry development
Computing power and intelligence of robot fog
Page Jump and database connection of student management system
Development of IOT device end - establishment of development environment
The data synchronization tool dataX has officially supported reading and writing tdengine
JVM调试工具-jvisualvm