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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:13:53+00:00 2026-06-03T03:13:53+00:00

I have a date string, returned from a ExtJS datetime picker, which looks like

  • 0

I have a date string, returned from a ExtJS datetime picker, which looks like this:

Wed Apr 25 2012 00:00:00 GMT+0300 (GTB Daylight Time)

From this I would need to have it in this format : YYYY-mm-dd, using C# or JavaScript.
How could I do this? I’ve tried using DateTime.Parse and it cannot be parsed.
Any idea?

  • 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-03T03:13:54+00:00Added an answer on June 3, 2026 at 3:13 am

    You don’t seem to care about the time and timezone information so you can in fact use DateTime.ParseExact to parse the date. Assuming that the day of month part may be just a single digit (e.g. 2012-04-01 is Sun Apr 1 2012) the pattern you need to use is ddd MMM d yyyy.

    The “hardest” part is really chopping of the time and timezone part. If the day of month is a single digit you have to take of substring of length 14; otherwise of length 15. Here is a way to get the index of the 4th space character in a string:

    var str = "Wed Apr 25 2012 00:00:00 GMT+0300 (GTB Daylight Time)";
    var index = -1;
    for (var i = 0; i < 4; i += 1)
      index = str.IndexOf(' ', index + 1);
    

    You can then parse the date into a DateTime:

    var date = DateTime
      .ParseExact(str.Substring(0, index), "ddd MMM d yyyy", CultureInfo.InvariantCulture);
    

    This can be formatted back into a string using whatever format and culture you need.

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

Sidebar

Related Questions

I have been passed a date string that looks like this: Thu%20Mar%2011%202010%2015%3A09%3A11%20GMT%2B0000%20(BST) I want
From a SOAP webservice, a date field is returned as the string: 2010-12-21T08:55:17E-7+01:00 which
I have an JSON string that gets returned from the server that i'm trying
I have the following long string returned from a SOAP call into a variable,
I have a string in standard ISO 8601 format that contains the date/time returned
I have a date string of the form '2009/05/13 19:19:30 -0400'. It seems that
I have a date string and I want to parse it to normal date
I have the following date as string 091020. I am using SubSonic as my
Hi I have the following date as String format. Input 2010-04-20 05:34:58.0 Output I
I have a service that give me a date time string in the following

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.