PDA

View Full Version : How do I... Please



summoner49
10-03-2005, 02:57 PM
what is the code to display a date and time on my webpage?

Chroder
10-15-2005, 03:19 AM
You can do it with a simple document.write, if you'd like. Take a look at the date object (http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Date) for more info (like getting full month names instead of a number etc).


The date is:
<script type="text/javascript">
var date = new Date();
var month = date.getMonth() + 1;
var day = date.getDate();
var year = date.getFullYear();
var s = "/";

document.writeln(month + "/" + day + "/" + year);
</script>

kink
11-05-2005, 10:28 PM
you will need a form named "sam" with an input box named "li"



<script type="text/javascript">
function twxfunction()
{
var re = new Date();
setTimeout("twxfunction()",1000)
var hys = re.getHours();
var myn = re.getMinutes();
var sec = re.getSeconds();
if (sec < 10)(sec = "0" + sec);
if (myn < 10)(myn = "0" + myn);
if (hys < 10)(hys = "0" + hys);
var h = document.sam.li.value;
document.sam.li.value = hys + ":" + myn + ":" + sec ;
}
</script>