我需要一个正则表达式来验证格式的时间戳,使用 Javascript:
I need a regular expression to validate a timestamp of the format, using Javascript:
YYYY/MM/DD HH:MI:SS
YYYY/MM/DD HH:MI:SS
我尝试了一些,但似乎我的正则表达式技能无法涵盖某些内容.
I tried cooking up a few, but seems my regex skills fail to cover something or other.
请给我一个参考或方法.
Please give me a reference or way to do it.
附注: 我提到正则表达式,只是作为一个建议.我使用 Javascript,欢迎任何替代方案.
我建议使用 Datejs这.不需要自己解析日期,并且正则表达式不足以验证时间戳.使用 datejs,您可以解析日期中的字符串,如果它无效,您将得到 null:
I would recommend to use Datejs for this. Parsing the date yourself is not necessary and a Regex is not enough to validate a timestamp. With datejs you could parse the string in a date and you'll get null if its invalid:
Date.parse("2009/06/29 13:30:10", "yyyy/MM/dd HH:mm:ss");
这篇关于正则表达式验证时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
检查一个多边形点是否在传单中的另一个内部Check if a polygon point is inside another in leaflet(检查一个多边形点是否在传单中的另一个内部)
更改传单标记群集图标颜色,继承其余默认 CSSChanging leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改传单标记群集图标颜色,继承其余默认
触发点击传单标记Trigger click on leaflet marker(触发点击传单标记)
如何更改 LeafletJS 中的默认加载磁贴颜色?How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默认加载磁贴颜色?)
将 Leaflet 图层控件添加到侧边栏Adding Leaflet layer control to sidebar(将 Leaflet 图层控件添加到侧边栏)
Leaflet - 在弹出窗口中获取标记的纬度和经度Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在弹出窗口中获取标记的纬度和经度)