I would like to pull the user's current date, time and timezone to store in the DB. Right now I do a new Date() but that gets the current date from the server. Any thoughts?
You have to use JavaScript on the client side to create the date into a html hidden field and send that to the server to store the Data on client's m/c.
Use the date object in javascript to accomplish this. This will create the date and store it in the client side javascript variable str, as well as in the hidden html variable currentDate.
Code:
<input type=hidden name=currentDate value=''>
<script language=javascript>
var now = new Date();
var str = '';
str += now.getMonth() + '/';
str += now.getDate() + '/';
str += now.getFullYear();
formName.currentDate.value = str;
</script>
Note: I use the date methods to form the string because javascript defaults to the January 1, 2004 format.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.