|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
GMT Problem
I maid an ASP in wich I used the Normal Time & Date Functions, One Problem Though The GMT That I have and the GMT the ASP Server Has are diffrent.
I Could of course add in the ASP the time diffrence to the Time function, But I also want it to be a 24-hour clock and the Server has a PM/AM clock. Is their a function or any other way that I Could Get The User's Time and not the Server's Time? Ben. |
|
#2
|
|||
|
|||
|
You can do it in client side javascript - by getting the utc date and looking at the offset from GMT at the end of the string.
Or, this is more server intensive.... Send the following code to the client, and if they have javascript enabled you'll get an immediate automatic POST back to "somepage.asp" with the form variable "tz" containing the users timezone offset. Note the manual override in case the user is not running javascript. You could enhance this and provide a form for the user to select their timezone if you do not get an automatic SUBMIT. <html> <body> <form name='detect' method='post' action='somepage.php'> <input type='hidden' name='tz' value='unknown'> </form> Detecting timezone... <a href='somepage.asp'>Click Here</a> if this page does not automatically redirect... <script type='text/javascript'> var now = new Date(); document.detect.tz.value = now.gettimezoneOffset(); document.detect.submit(); </script> </body> </html> |
|
#3
|
|||
|
|||
|
Thanks a lot, But is this function (now.gettimezoneOffset) availble only in javascript?
Is it availble in VBscript or plain ASP? |
|
#4
|
|||
|
|||
|
as far as i know
you can mix javascript and vbscript if that's what you're worried about |
|
#5
|
|||
|
|||
|
The script I wrote dosen't work, An error is recived:
"A runtime error has occurred... Line: 18 Error: Object Dosen't Support property or method." what should I do? |
|
#6
|
|||
|
|||
|
probably post your code =P
|
|
#7
|
|||
|
|||
|
I ment that Your Script Didn't work:
<html> <body> <form name='detect' method='post' action='somepage.php'> <input type='hidden' name='tz' value='unknown'> </form> Detecting timezone... <a href='somepage.asp'>Click Here</a> if this page does not automatically redirect... <script type='text/javascript'> var now = new Date(); document.detect.tz.value = now.gettimezoneOffset(); document.detect.submit(); </script> </body> </html> " with the same error message... |
|
#8
|
|||
|
|||
|
hmmmm.... I'm not getting any errors, but the date (gettimezoneoffset) method isn't working.... I must have errors turned off or something.....
var rightNow = new Date(); var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0); var temp = date1.toGMTString(); var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); var temp = date2.toGMTString(); var date4 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60); var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60); if (hoursDiffDaylightTime == hoursDiffStdTime) { alert("Time zone is GMT " + hoursDiffStdTime + ".\nDaylight Saving Time is NOT observed here."); } else { alert("Time zone is GMT " + hoursDiffStdTime + ".\nDaylight Saving Time is observed here."); } this i know works, it will give you the time zone offset of grinnich mean time.... i'll get back to you on the other script... i'm not sure why that method wouldn't work anymore..... |
|
#9
|
|||
|
|||
|
OK, now i need help, why won't the get timezone above work but here it will work?
<script type='text/javascript'> var now = new Date(); document.writeln("<h3>The offset from GMT is "+now.getTimezoneOffset()+"</h3>"); This is frustrating..... well there's 2 functions you can use for hours or minutes offset, i can't explain why that first one isn't working..... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > GMT Problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|