JS get current date code for Web page header

Source: Internet
Author: User
Tags datetime

The

Code is as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
<meta http-equiv= "Content-type" content= "text/html; charset=utf-8"/>
<script t Ype= "Text/javascript" >
function Bodyload () {
var datetime=new Date ();
var hh=datetime.gethours ();
if (hh<10) hh = ' 0 ' + hh;
var mm=datetime.getminutes ();
if (mm<10) mm = ' 0 ' + mm;
var ss=datetime.getseconds ();
if (ss<10) ss = ' 0 ' + ss;
var yy=datetime.getfullyear ();

var mm=datetime.getmonth () +1;//Since January This method returns 0, so add 1
var dd=datetime.getdate ();
var week=datetime.getday ();
var days=["Day", "one", "two", "three", "four", "five", "six",]
document.getElementById ("date"). value=yy+ "Year" +mm+ "month" +dd+ "Day "+" Week "+days[week];
document.getElementById ("Time"). value=hh+ ":" +mm+ ":" +SS;
SetTimeout (bodyload,1000);
}
</script>
<body onLoad= "Bodyload ()" >
<input type= "text" id= "date" style= "border:0 none;"/><input type= "text" id= "Time" Style= "border:0 none;"/>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.