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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:39:19+00:00 2026-05-23T07:39:19+00:00

An api im using is providing me a date. This date is of type

  • 0

An api im using is providing me a date. This date is of type string and is presented in the format:

Mon Nov 16 19:15:09 +0000 2009

DateTime.TryParse() fails when this value is provided. Can anyone point me in the right direction?

  • 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-23T07:39:19+00:00Added an answer on May 23, 2026 at 7:39 am

    Using the DateTimeOffset class in order to handle the offset.

    [TestMethod]
    public void test()
    {
      string s = "Mon Nov 16 19:15:09 +0000 2009";
    
      var result = DateTimeOffset.ParseExact(
        s, 
        "ddd MMM dd HH:mm:ss zzz yyyy", 
        System.Globalization.CultureInfo.InvariantCulture);
    
      Assert.AreEqual(16, result.Day);
      Assert.AreEqual(11, result.Month);
      Assert.AreEqual(2009, result.Year);
      Assert.AreEqual(19, result.Hour);
      Assert.AreEqual(15, result.Minute);
      Assert.AreEqual(9, result.Second);
      Assert.AreEqual(0, result.Offset.Hours);    
    }
    

    Change the offset in the string – e.g. ‘0600’ and then change the offset assertion to match, it’ll work.

    You can then convert this into a DateTime if you have to – but you lose the offset information; so you have to decide whether you’re going to keep it as the original local time (19:15:09), or if you’re going to convert to some standard time (e.g. 13:19:05 UTC if offset is +06:00).

    It gets interesting if you need to convert that to your own local time – because it would depend on what DST rules were in place in 2009 at that time of the year – that can cause a real headache!

    So, if you’re going to DateTime I recommend converting to universal time and then go from there. Add this to the test:

    Console.WriteLine(result);
    //little bit long winded - but you need the 'Universal' Kind for reliability
    Console.WriteLine(
      DateTime.SpecifyKind(
        new DateTime(result.ToUniversalTime().Ticks), 
        DateTimeKind.Utc)
    );    
    

    This outputs:

    11/16/2009 19:15:09 +06:00

    11/16/2009 13:15:09

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

Sidebar

Related Questions

implementing publishActivity in PHP using the REST API using this code: $activity = array(
I'm using the Windows API GetNumberFormatEx to format some numbers for display with the
I am using some web API that operates by providing an API key (40
From the native Win32 API using C++ is there a way to determine whether
Am building a Book search API using Lucene. I need to index Book Name,Author,
I'm implementing a REST API using ASP.NET MVC, and a little stumbling block has
I'm trying to access a SOAP API using Suds. The SOAP API documentation states
I'm busy implementing the wurfl api using PHP, but somehow just can't seem to
I try to use amazon API using PHP. If I use print_r($parsed_xml->Items->Item->ItemAttributes) it show
I want to create Task in Google Calendar using Google Calendar API.Using C#. Looking

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.