Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 765277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:51:49+00:00 2026-05-14T16:51:49+00:00

I have a database that holds a time as UTC. This time can be

  • 0

I have a database that holds a time as UTC. This time can be shown in a webpage, so I’ve been asked to show it as local time in the page as it can be viewed from any country. A colleague mentioned something about getting the country settings from the current thread (on the server) but I couldn’t find any details on this. Is what I want to do possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:51:50+00:00Added an answer on May 14, 2026 at 4:51 pm

    If you (and your website) are comfortable with javascript, there is a very easy way to accomplish this.

    First, on the server side, you would have the UTC date/time formatted in RFC 3339 format (the standard for internet time used by, among other protocols, icalendar). The basic syntax of RFC 3339 is:

    YYYY-MM-DDTHH:MM:SS
    

    Such that where I am, the time would be:

    2010-05-04T05:52:33
    

    But when the time is not local, but UTC, you add a Z to the end to denote this. So in my case, since I’m at -0500 hours from GMT, the same time above would be:

    2010-05-04T10:52:33Z
    

    So, first you get the server to output the above to your web page’s javascript. The javascript can then parse that timestamp and it will output the date and time adjusted to the browser’s time zone (which is determined by the computer hosting the browser). You should remember that if a user is from Tokyo and is viewing your website in Spain, they will see the timestamp in Tokyo time unless they’ve adjusted their computer’s clock.

    So the javascript would be:

        var time_string_utc = some_server_variable; // timestamp from server
        var time_string_utc_epoch = Date.parse(time_string_utc);
        var time_utc = new Date();
        time_utc.setTime(time_string_utc_epoch);
    

    At this point, you have a javascript date object set to your UTC timestamp. A quick explanation of what happens above:

    The first variable assumes you have passed the timestamp string to that variable from the server.

    The second variable uses the Date.parse() method to convert the string to an epoch timestamp.

    The third variable creates the unset Date object.

    The last line line uses setTime method, which sets a Date object from an epoch timestamp.

    Now that you have the object, you can output it to the user as you see fit. As a simple experiment, you can use:

    document.write(time_utc);
    

    which, if you are in my timezone using the UTC timestamp I started off with:

    2010-05-04T10:52:33Z
    

    would give:

     Tue May 04 2010 05:52:33 GMT-0500 (CST)
    

    but you can use various javascript methods to format the time into something much more pleasant looking.

    No need to guess the user’s country or even adjust your timestamp, so long as you trust the user’s local browser/computer time zone.

    Again, the short version:

        var time_string_utc = some_server_variable; // UTC time from server
        var time_string_utc_epoch = Date.parse(some_server_variable);
        var time_utc = new Date();
        time_utc.setTime(time_string_utc_epoch);
        document.write(time_utc);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database column WantsReply that logically holds a boolean (bit) but is
I have a database that contains a table that looks a bit like this:
I have a table in my database that holds numerical values collected from a
I have a database that hold's a user's optional profile. In the profile I
I currently have a SQL Server (Express 2005) database to hold some transaction/metadata that
I have a database that contains a date and we are using the MaskedEditExtender
I have a database that I would like class files generated from, and also
I have a database that many different client applications (a smattering of web services,
I have a database that i'm dealing with which is updated every few hours
I have a database that is stuck in single-user mode. I kill the process

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.