`

判断字符串是否是时间

 
阅读更多

        //================================================
        // 说明:判断字符串是否是时间(js)
        //------------------------------------------------
        function IsTime(dateString) {
            dateString = $.trim(dateString);
            if (dateString == null && dateString.length == 0) {
                return false;
            }

            dateString = dateString.replace(/\//g, "-");
            var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
            var r = dateString.match(reg);
            if (r == null) {
                var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
                var r = dateString.match(reg);
            }

            return r != null;
        }

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics