View Full Version : date time
randyw2394710
04-13-2011, 07:39 AM
i have two forms
profile page i would like to have the user edit page then add time date automaticly to data base i already use time stamp
also in the contact page i use timestamp for date time filled out how do i make it the users local time not server
the data base is aalso attached
both local user date time stamp
Jason Byrnes
04-14-2011, 12:28 PM
to get the date form the client computer, you would need to use javascript to set a hidden form element, then in the insert record behavior, bind the date column to the hidden form element.
put this script in the head of your page before the </head> tag:
<script type="text/javascript">
function setDate() {
var theDate = new Date();
var dateStr = theDate.getMonth()+'/'+theDate.getDay()+'/'+theDate.getFullYear();
document.getElementById('form1').formdate.value=da teStr;
}
</script>
This script assumes that the form ID is "form1" and the hidden form element is named "formdate" if you use different form ID and element name, you will need to edit the script
then set the body onload event to call the function:
<body onLoad="setDate()">
Then when binding the date column to the new formdate hidden form element, the code produced will be:
<?php echo((isset($_POST["formdate"]))?$_POST["formdate"]:"") ?>
add the strtotime function to convert the date to the timestamp format:
<?php echo((isset($_POST["formdate"]))?strtotime($_POST["formdate"]):"") ?>
randyw2394710
04-17-2011, 07:51 AM
How do I get time from client computer aswell
Jason Byrnes
04-18-2011, 11:34 AM
use the getHours() getMinutes() and getSeconds() functions in the dateStr variable. See the following page for details on the javascript date function:
http://www.tizag.com/javascriptT/javascriptdate.php
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.