js whether the current time in a certain period of time

js determined whether the current time (or a selected time) is a period of time

We can use jutils - commonly used JavaScript libraries isDuringDate functions to achieve

Incoming beginDateStr (start time), endDateStr (End Time)

Instructions

jutils.isDuringDate('2018/09/17', '2030/09/17');
// 当前时间是否在2018/09/17 - 2030/09/17 之间,输出 true
 
 
jutils.isDuringDate('2018/09/17 13:00', '2019/09/17 15:00');
// 当前时间是否在2018/09/17 13:00 - 2019/09/17 15:00 之间,输出 false
 
 
jutils.isDuringDate('2018-09-17 13:00', '2019-09-17 15:00');
// 当前时间是否在2018/09/17 13:00 - 2019-09-17 15:00 之间,输出 false

Source

/**
 * [isDuringDate 比较当前时间是否在指定时间段内]
 * @author dongsir
 * @DateTime 2019-08-21
 * @version  1.0
 * @param    date   [beginDateStr] [开始时间]
 * @param    date   [endDateStr]   [结束时间]
 * @return   Boolean
 */

Javascript whether the current time in a certain period of time

Guess you like

Origin www.cnblogs.com/sirdong/p/11542153.html
Recommended