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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:54:59+00:00 2026-05-23T01:54:59+00:00

How can I convert the time from the format Thu Jun 09 2011 00:00:00

  • 0

How can I convert the time from the format “Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)” to YYYY-MM-DD.

When I try to alert() the date then this will show the date like the following
– Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)

But I need the time in YYYY-MM-DD format.

Are there any built function to convert?

  • 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-23T01:54:59+00:00Added an answer on May 23, 2026 at 1:54 am

    You can parse the date using the Date constructor, then spit out the individual time components:

    function convert(str) {
      var date = new Date(str),
        mnth = ("0" + (date.getMonth() + 1)).slice(-2),
        day = ("0" + date.getDate()).slice(-2);
      return [date.getFullYear(), mnth, day].join("-");
    }
    
    console.log(convert("Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)"))
    //-> "2011-06-08"

    As you can see from the result though, this will parse the date into the local time zone. If you want to keep the date based on the original time zone, the easiest approach is to split the string and extract the parts you need:

    function convert(str) {
      var mnths = {
          Jan: "01",
          Feb: "02",
          Mar: "03",
          Apr: "04",
          May: "05",
          Jun: "06",
          Jul: "07",
          Aug: "08",
          Sep: "09",
          Oct: "10",
          Nov: "11",
          Dec: "12"
        },
        date = str.split(" ");
    
      return [date[3], mnths[date[1]], date[2]].join("-");
    }
    
    console.log(convert("Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)"))
    //-> "2011-06-09"
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I convert a date time format from JSON.Net such as: /Date(1154970000000+0700)/ To
i fetched from created field date and time like this format 2011-3-10 17:26:50 and
I've occured a strange time-format, and i can't figure out how to convert it
How can convert my time received from my $_GET variables as two digit values
If I do the following I can convert from a time_struct object to a
How can I convert a date time string of the form Feb 25 2010,
How can I convert a string to a date time object in javascript by
How can I convert seconds into (Hour:Minutes:Seconds:Milliseconds) time? Let's say I have 80 seconds;
Can anyone suggest an easy method to convert date and time to different timezones
I'm using SSRS 2005 and I need to convert time from a serial unix

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.