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.

  Re: Time Zone check in Java and PHP  MattoThePotatto at 08:37 on Wednesday, June 25, 2008
 

Don't know much about javascript, so there is probably an easier way..
But you may be able to do this..
var date = new Date();
var timezone = date.substr(?,?);
if(timezone=="12")
{
timezone=12;
)
if(timezone=="11")
{
timezone=11;
}
... <And so on for all the timezones>
(Get a string of the users timezone ... Convert it into a number and use that ..?








CodeToad Experts

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








Recent Forum Threads
• Re: Insert Contents of .txt file into a .html page
• Re: Perl regular expression problem.
• Re: Problems in login using WWW::Mechanize
• searching for gd::graph guide
• Re: ARRAY OF HASHMAPS
• Adv. Regexp or Otherwise
• Adv. Regexp or Otherwise
• I need help pleasee! My project is about using I/o Stream
• Help Running VB script in Windows 2003


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