当前位置:网站首页>检查日期是否有效
检查日期是否有效
2022-07-20 04:08:00 【紫微前端】
检查是否可以从给定的值创建有效的日期对象。
- 使用扩展运算符 (
...
) 将参数数组传递给Date
构造函数。 - 使用
Date.prototype.valueOf()
andNumber.isNaN()
检查是否Date
可以从给定值创建有效对象。
const isDateValid = (...val) => !Number.isNaN(new Date(...val).valueOf());
isDateValid('December 17, 1995 03:24:00'); // true
isDateValid('1995-12-17T03:24:00'); // true
isDateValid('1995-12-17 T03:24:00'); // false
isDateValid('Duck'); // false
isDateValid(1995, 11, 17); // true
isDateValid(1995, 11, 17, 'Duck'); // false
isDateValid({}); // false
边栏推荐
- Protocol details of network principles
- [upload range 12-16] cut, picture horse
- Several common models of convolutional neural network CNN
- Excel管理Simulink SWC中的标定量与观测量之标定量
- Processus et fils
- Caffeine缓存增改查过期
- [special for training courses] Introduction to tee components
- Leetcode sword finger offer 32 - I. print binary tree from top to bottom
- Use DOS command to generate directory file tree
- 请别再使用 SimpleDateFormat 格式化时间了,DateTimeFormatter 更出色!
猜你喜欢
动态内存管理
青海vr消防模拟演练系统,满足了对多人群多场景下的培训需求
BOM browser object model (Part 1) - overview, common events of window object, JS execution mechanism (close advertisement after 5 seconds, countdown case, send SMS countdown case)
负载均衡使用
Leetcode sword finger offer 32 - I. print binary tree from top to bottom
Solve gradient explosion and gradient disappearance
Excel管理Simulink SWC中的标定量与观测量之标定量
Share a fun JS game
kvm虚拟化
This beta version of Typora is expired,please download and install a newer version.
随机推荐
redis回顾
详解激活函数
使用Dos命令生成目录文件树
36-【go】Golang的IO流
BOM浏览器对象模型(下篇)—— offset、client、scroll三大家族、插件及本地存储特性(案例:仿京东放大镜、模态框拖拽)
Reasons why loss does not decrease
Redis review
The difference between voice message and voice notification in okcc call center
Trax:如何打赢夏日冰淇淋市场的甜蜜之战?
机器学习之集成学习(Ensemble Learning)
Hands on experiment of network and VPC
负载均衡使用
简略break、continue、return的区别
With the advent of 5g era, VR panoramic production is an industry worthy of entrepreneurship
详解FCOS《FCOS: Fully Convolutional One-Stage Object Detection》
给家长的手机补修课
Processes and threads
特殊类的设计(单例模式)
36 - [go] io flow of golang
目标检测的进阶-one stage