Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 15:55:29
Original
1425 people have browsed it

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

Date.parse(datestring)

Copy after login

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

下面是参数的详细信息:

  • 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>

Copy after login

这将产生以下结果:

Number of milliseconds from 1970: 1215455400000 

Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!