Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q785 How do I pass the client's local time to a server side process?

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>

©2018 Martin Webb