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 8343625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:07:25+00:00 2026-06-09T06:07:25+00:00

I receive a date time as a string from the server that might look

  • 0

I receive a date time as a string from the server that might look like this:

07/08/2012 13:17:32

This is a UTC time.

Or it might have timezone in format:

07/08/2012 13:17:32 UTC+01:00

I need a general way to parse this into a Date object for display. If I do a var d = new Date(str) then the first example it assumes is a local time.

Edit:
It might not always be ‘UTC’ in the string, I think it could be GMT, or Z, or any other timezone signifier.

Any ideas?

  • 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-06-09T06:07:26+00:00Added an answer on June 9, 2026 at 6:07 am

    If your timezone is always in format UTC+nn, and strings with explicit UTC TZ are parsed correctly, as I assume from your question, then simple

    if (date_string.search(/a-z/i) == -1) {
     date_string += 'UTC+00:00'
    }
    

    will do.

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

Sidebar

Related Questions

I receive a date-time from automation system like this: 00:00:30:00 . When I try
I receive Date and time from CSV file The received Date format is YYYYMMDD
I am having a problem with formatting a date that I receive from a
Below are the date strings received from the server 2012-07-05T11:18:00-04:00 or 2012-12-05T10:26:00-05:00 As far
I'm having a hard time Parsing/Formatting a Date string received back from a web
I received DateTime String from Fedex in following format 2012-06-22T21:39:48-05:00 I want to convert
I receive a date in the format below from a json file. Im not
I get the Error sometime on Converting 12hour format time from a Timezone to
Whenever I run this script, I receive the error Conversion failed when converting date
how would I format a datetime string received from MySQL? For example, when I

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.