Jump to content

local time code help


paulmo

Recommended Posts

along with php script on separate page, here's some js (on html form page) to try to get local time from user form (only gettting server time now). could someone please help me with this? thanks

<script type="text/javascript">function main(){	var hours = (new Date()).getHours();	var offset = document.getElementById('offset');	offset.value = hours - offset.value;}</script></head><body onload="main();">

Link to comment
Share on other sites

Why not do this

function main(){	var date = new Date();	var time = date.getHours + ":" + date.getMinutes;	var offset = document.getElementById('offset');	offset.value = time;}

Now you have the exact time on the client machine (24 hour clock).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...