aspose file tools*
The moose likes JSP and the fly likes want client's time zone from server side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "want client Watch "want client New topic
Author

want client's time zone from server side

prajyot jadhav
Greenhorn

Joined: Dec 26, 2011
Posts: 6
"want client's time zone from server side":--
i am using an web application which runs on remote server, it shows the time and date in EST format as that of its server but i want to display that in its client's timezone
i tried to make so many changes in JSP and Java action classes but it always gives time in EST i.e. server side format....

can anyone please help me how can i get timezone of client which could be in any timezone..?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
You could use the client's IP adress to determine (approximately) her country and possibly city. That could be used to obtain the timezone. Alternatively, embed JavaScript code that contacts the server with the client-side time. The Java/JSP code running on the server will only ever give you the server time, so that's a dead end.
prajyot jadhav
Greenhorn

Joined: Dec 26, 2011
Posts: 6
Thanks Tim..., could you please suggest how can i get client location from his IP in java or jsp
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

You could use some Javascript code which converts a date in the server's time zone to the corresponding date in the client's time zone. You'll notice that this forum displays times in your timezone; that's because it uses that Javascript code.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: want client's time zone from server side