var DATE_REGEXP = new RegExp("(\\d{4})-(\\d{2})-(\\d{2})([T\\s](\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{3}))?)?.*");
    function toDate(dateString){
        if(DATE_REGEXP.test(dateString)){
            var timestamp = dateString.replace(DATE_REGEXP, function($all,$year,$month,$day,$part1,$hour,$minute,$second,$part2,$milliscond){
                var date = new Date($year, $month,$day, $hour||"00", $minute||"00", $second||"00", $milliscond||"00");
                return date.getTime();
            });
            var date = new Date();
            date.setTime(timestamp);
            return date;
        }
        return null;
    }

 

相关文章:

  • 2022-02-08
  • 2022-01-01
  • 2021-11-15
  • 2021-08-15
  • 2021-11-29
  • 2021-06-05
  • 2022-12-23
猜你喜欢
  • 2022-02-08
  • 2022-02-08
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
相关资源
相似解决方案