codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Time Zone check in Java and PHP  sunder at 08:01 on Saturday, April 12, 2008
 

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.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  can anyone pinpoint the error.
•  how to create forum using asp.net with c# language?
•  Time Zone check in Java and PHP
•  calculating date using javascript
•  DataGrid
•  Re: dynamic crystal report generation
•  datasource
•  Re: How to time out an operation?
•  How to reduce code length


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008