Web Design and Development Forums

Javascript Timezone Check

This is a discussion on "Javascript Timezone Check" within the JavaScript Forum section. This forum, and the thread "Javascript Timezone Check are both part of the Program Your Website category.

Old Apr 12th, 2008, 08:09   #1 (permalink)
New Member
 
Join Date: Apr 2008
Location: Hungary
Posts: 2
Javascript Timezone Check

Hi all,
I am in the challenging effort to put together a time zone check for users using a global application originally written in PHP.
Sadly, it seems I struck at a point to I am trying to gather some help in these forums.
Problem is the following:
the server saves time zone information in the user profile, and it will keep a value of the difference between the Users time and the Server time.
Assuming the Server is GMT+1 and the user is GMT-7, the diff will be -8 hours.
On the other hand, if the server is GMT+1 and the user is GMT+6, the stored diff will be 5 hours.
Now to avoid typos and user problems, I want to run a small script at login that compares the user's PC time to the databases assumed time.
The problem I face: I use UNIX timestamps to store values.
I tried every single Java code I knew and also what I could find, but as soon as I want to convert the USER-SIDE date to a timestamp it will return the SERVER's time as a timestamp e.g. parse();
So:
// Get the user's time from his or her PC
d = new Date( );

If I use d.getFullYear(), d.getDate() etc. this will accurately return the user's time, e.g.
2008-Jan-25 15:20
But if I use this info and try to parse() the string, the timestamp returned will actually be the Server's time!
So, anyone has any good ideas how to solve this timezone-check riddle?
Thanks in advance.
sunder is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 12th, 2008, 17:39   #2 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 517
Blog Entries: 4
Re: Javascript Timezone Check

i would use PHP or some other server side language to do this. there's no need for javascript.
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 12th, 2008, 20:10   #3 (permalink)
New Member
 
Join Date: Apr 2008
Location: Hungary
Posts: 2
Re: Javascript Timezone Check

Thanks for the prompt answer CloudedVision.

Actually, I am already utilizing PHP to get the server side time and also, the REQUIRED time for the user based on the saved time difference data.

However, I can not use server side to determine what is the time on the user's PC, and actually this script would need to check if the server side data is accurate.

The challenge here: I could make a comparison of JAVA user time string and PHP server side string to see if it matches even without converting the user side time to a unix timestamp, BUT, here is an example where this fails:

user time string: 2008-Apr-12 14:59
server required string: 2008-Apr-12 15:01

I wanted a 3 minutes threshold that is acceptable as the difference between server side and user side, but in this case I can not calculate it without using timestamps since not even the hours match.

I could make EXCEPTIONS but that would take lots and lots of rows and resources.

That is why I asked this question if anyone knows a better solution for this trouble.
sunder is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
javascript, parse, server time, time zone, user time

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why cant i check the filetype??!! Accurax PHP Forum 2 Dec 15th, 2006 09:52
First website - check it out!! webdesign4life Free Web Site Critique 4 Sep 2nd, 2006 16:29
check if Javascript is enabled and take actions ktsirig JavaScript Forum 0 Apr 11th, 2006 20:18
Hello, check this ;) Anonymous User Introduce Yourself 1 Feb 12th, 2004 19:10



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 11:42.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59