Forum Moderators: open
function showlocaltime() {
var today = new Date();
var difftime = (today.getTimezoneOffset()+240) *60000;
today.setTime(today.getTime()+difftime);
alert(today.toLocaleString());
}
//240=4*60 because my local time is GMT+4
Here is the ASP page .. which stores record in Table ... How can I change the function now() to the generated value of Javascript function?
rstSearch.CursorType = 2
rstSearch.LockType = 3
strSQL= "SELECT * FROM tblMessages"
rstSearch.Open strSQL, adoCon
rstSearch.AddNew
rstSearch.Fields(1)=session("username")
rstSearch.Fields(2)=request.Form("textfield")
rstSearch.Fields(3) =request.Form("textfield2")
rstSearch.Fields(4)=request.Form("textarea")
rstSearch.Fields(5)=now 'NEED TO CHANGE
rstSearch.Fields(6)=false
rstSearch.update
rstSearch.close
response.Redirect("messages.asp?id=4") Regards,
function showlocaltime() {
var today = new Date();
var difftime = (today.getTimezoneOffset()+240) *60000;
today.setTime(today.getTime()+difftime);
document.forms.frmMessagesent.hiddenField.value=today.toLocaleString();} Above written code returns the date in following format.
Monday, May 23, 2005 12:59:14
Which cannot be stored as a date/time value in MSACCESS and SQL SERVER date/time fields.
Any Idea, how can we convert it (date and time both), USING ASP or it should be done using javascript?
Regards,
hazee-
Instead of populating your hidden field via JavaScript, you should do it via ASP:
<input type = "hidden" name = "myname" value = "<%=DateAdd("h", 4, Now())%>">
This will add 4 hours onto your server time.
Instead of populating your hidden field via JavaScript, you should do it via ASP:
<input type = "hidden" name = "myname" value = "<%=DateAdd("h", 4, Now())%>">
This will add 4 hours onto your server time.
It was helpful, although I had to calculate the difference between the time of server and our local timings. Anyways ..
Thanks and regards.
The answers to all your problems should be solved here:
[slingfive.com...]
My 36 hours of misery were put to rest in 15 minutes.