Automatically determine browser time zone?

Posted on 2006-04-12
Last Modified: 2006-11-18
I'm developing an application that will be used worldwide.  I think I need to handle and store all dates on the server in GMT time, so I can use TimeZone.setDefault() to set all times to "GMT".  Is that the best approach?  If so, then so far, so good.  

Now, how do I display dates and times on a JSP page in the user's time zone?  I have read up on <fmt:formatDate> and the various time zone tags, but they all assume that I give them the time zone to use.  I don't know what time zone the user is in.  Isn't that something that can be determined by the browser?

Also, when the user inputs a date without a time into a JSP form, how do I convert that back to GMT if I don't know the user's time zone?
Question by:GaryW021199
    1 Comment
    LVL 3

    Accepted Solution

    I believe the question is server time vs client time. Since that JSP is the server-side web server, you cannot  determine the Client time from JSP. Remember that the JSP compiled in the server not the client browser. What I suggest to do is to use javascript to pass the client time to the server from HTML form submit.

    Hope it helps.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Outlook Free & Paid Tools
    The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now