Home  >  Article  >  Web Front-end  >  JavaScript中的parse()方法使用简介_基础知识

JavaScript中的parse()方法使用简介_基础知识

WBOY
WBOYOriginal
2016-05-16 15:55:291426browse

 Javascript Date.parse() 方法接受一个日期字符串,并返回自1970年1月1日午夜的毫秒数。
语法

Date.parse(datestring)

注:括号内的数据是可选的

下面是参数的详细信息:

  •     datestring : 一个字符串,表示日期

返回值:

自1970年1月1日午夜的毫秒数。
例子:

<html>
<head>
<title>JavaScript parse Method</title>
</head>
<body>
<script type="text/javascript">
  var msecs = Date.parse("Jul 8, 2008");
  document.write( "Number of milliseconds from 1970: " + msecs ); 
</script>
</body>
</html>

这将产生以下结果:

Number of milliseconds from 1970: 1215455400000 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn