You are here: irt.org | FAQ | JavaScript | Date | Q785 [ previous next ]
Either using a form submission:
<form name="myForm"> <input type="hidden" name="myTime" value=""> </form> <script language="JavaScript"><!-- function padout(number) { return (number < 10) ? '0' + number : number; } var today = new Date(); document.myForm.myTime = escape(padout(today.getHours()) + ':' + padout(today.getMinutes()) + ':' + padout(today.getSeconds())); //--></script>
Or as part of an image load request:
<script language="JavaScript"><!-- function padout(number) { return (number < 10) ? '0' + number : number; } var today = new Date(); document.write('<img src="program.cgi?' + padout(today.getHours()) + ':' + padout(today.getMinutes()) + ':' + padout(today.getSeconds()) + '" width="1" height="1">'); //--></script>