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

  • SEARCH
  • Home
  • 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 6737375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:14:29+00:00 2026-05-26T11:14:29+00:00

I have a problem converting a timestamp in javascript. I have this timestamp: 2011-10-26T12:00:00-04:00

  • 0

I have a problem converting a timestamp in javascript.

I have this timestamp:

2011-10-26T12:00:00-04:00

I have been trying to format it to be readable. So far, it converts this using the local time of my system instead of the GMT offset in the timestamp. I know the timezone that this was created in is EST. I’m in PST, so the times are being offset by 3 hours.

Instead of this showing as:

Wednesday October 26, 2011 12:00 pm

It shows as:

Wednesday October 26, 2011 9:00 am

I have tried a few different solutions, but the latest one is found here: http://blog.stevenlevithan.com/archives/date-time-format

I am less concerned with the formatting part as I am with figuring out how to handle the GMT offsets. Would appreciate any help and insight anyone can provide.

  • 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-26T11:14:30+00:00Added an answer on May 26, 2026 at 11:14 am

    Date objects are created in the local zone. If the date string was created in a different time zone, then you need to adjust the date object to allow for the difference.

    The abbreviations PST and EST are ambiguous on the web, there is no standard for time zone abbreviations and some represent two or zones. You should express your zone only in terms of +/- UTC or GMT (which are the same thing, more or less).

    You can get the local time zone offset using Date.prototype.getTimezoneOffset, which returns the offset in minutes that must be added to a local time to get UTC. Calculate the offset for where the time string was created and apply it to the created date object (simply add or subtract the difference in minutes as appropriate).

    If your time zone is -3hrs, getTimezoneOffset will return +180 for a date object created in that zone. If the string is from a zone -4hrs, its offset is +240. So you can do:

    var localDate = new Date('2011-10-26T12:00:00') // date from string;
    var originOffset = 240;
    var localOffset = localDate.getTimezoneOffset();
    localDate.setMinutes( localDate.getMinutes() + originOffset - localOffset );
    

    Adding the origin offset sets it to UTC, subracting the local offset sets it to local time.

    It would be much easier if the time string that was sent by the server was in UTC, that way you just apply the local offset.

    Edit

    IE will not parse a time string with an offset, and Chrome thinks that the above time string is UTC and adjusts for local offset. So don’t let Date parse the string, do it manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem converting a string binary to a decimal I was using
I have problem with datetime format for C# and T-SQL. C# application is using
I have some problem converting a MYSQL query to CI syntax. This my MySQL
I have problem, when converting Windows application from .NET2.0 to .NET3.5. I do this
I have a problem in converting the Unix timestamp to sql server timestamp. I
I have a problem using the MySQLdb library. I'm trying to insert values into
I have some problem regarding converting/truncating a number. This is the condition: x.35 where
Problem I have a timestamp that I am converting to an NSDate . Now
I have A problem regarding Converting Xaml to C# , I m using Auto
I have a problem while converting a string whose value is dd.mm.yyyy to DateTime

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.