JavaScript 日期函数

JavaScript Date 函数用于返回当前的日期和时间。在本文中,我们将通过示例向您展示如何使用 Date 方法。

下面的 JS 示例将帮助您理解此函数。

<!DOCTYPE html>
<html>
<head>
    <title> Sample </title>
</head>
<body>
    <h1> Example </h1>
<script>
  var dt = Date();
    
  document.write("DateTime :   " + dt);
</script>
</body>
</html>
Example

DateTime: The Nov 01 2018 11:32:39 GMT+0530 (Indian Standard Time)