PDA

View Full Version : code for date


sher_amf
01-08-2008, 10:48 AM
how do you put a date on your website?
like on the lower right there is a time and date hopefully..
like it is place in a textbox how do you do that?

davidj
01-08-2008, 11:33 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript">

function getT(){
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();

fld = document.getElementById('txt');

result = day +"/"+month+"/"+year;

fld.innerHTML = result;
}

</script>
</head>
<body onload="getT()">
<div id="txt"></div>

</body>
</html>