首页javascriptmoment_jsJavascript Data Type - 如何从12小时格式的日期和时间字符串创建新日期

Javascript Data Type - 如何从12小时格式的日期和时间字符串创建新日期

我们想知道如何从12小时格式的日期和时间字符串创建新日期。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-compat-git.js'></script>
<script type='text/javascript'
  src="http://momentjs.com/downloads/moment.min.js"></script>
<script type='text/javascript'>
$(window).on('load', function() {
    var datestr = "2014-12-31 11:59 pm";
    var date = moment(datestr,"YYYY-MM-DD HH:mm a")
    $("#log").text(date.format("HH:mm:SS MMM DD YYYY"));
});
</script>
</head>
<body>
  <div id="log"></div>
</body>
</html>