html+js获取系统当前日期并输出

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>如何获取系统日期title>

<script language="javascript" type="text/javascript">

//js获取日期

function time()

{

  var now= new Date();

  var year=now.getFullYear();

  var month=now.getMonth();

  var date=now.getDate();

//写入相应id

 document.getElementById("info1").innerHTML="今天是:"+year+"年"+(month+1)+"月"+date+"日";

document.getElementById("info2").innerHTML="今天是:"+year+"年"+(month+1)+"月"+date+"日";

} 

script>

head>

<body onload="time()">



<table width="100%" border="1">

  <tr>



       <td id="info1">td>

 <td id="info2">td>

  table>

body>

html>

你可能感兴趣的:(HTML)