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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:54:04+00:00 2026-06-13T23:54:04+00:00

I am trying to convert a string to a datetime I have been using

  • 0

I am trying to convert a string to a datetime

I have been using

DateTime convertedDate = DateTime.Parse(lastModificationDate);

to convert the date

my problem is, sometimes the date will be in UK format and sometimes in US format

ie UK 11/09/2011 10:34
US 2/28/2010 13:56

How can I handle both formats when I am not sure which format the string will be in, ie us or uk?

  • 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-13T23:54:06+00:00Added an answer on June 13, 2026 at 11:54 pm

    You fundamentally can’t. You don’t have enough data. As a human, which date is involved here?

    11/09/2011 10:34
    

    Is that 11th of September or 9th of November?

    If you can’t tell the difference as a human, there’s no chance of a computer doing so.

    Now if you can get a signal from elsewhere in the same data source, then that’s a start – for example, you could heuristically try to parse all the dates as US format, and all the dates as UK format, and if 100% pass as UK format but 60% fail in the US format (due to trying to days being parsed as invalid months) then you could reasonably assume they’re UK dates.

    That’s never going to be a complete solution though – because you could have one data source with a bunch of dates which are all valid (but with different meanings) in both formats.

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

Sidebar

Related Questions

I am trying to convert a string into date time format. DateTime.Parse(tempfrmBankDetails.dgvBankDetails.SelectedRows[0].Cells[PaymentDate].Value.ToString(),null); This is
I'm trying to convert a string to a time using DateTime.parse in a scope
I have a string of a date: 25/08/2012 And here I'm trying to convert
I have been trying to convert between timezones a given date and time. Code
I'm trying to convert a string from to a Joda DateTime object. The date
I'm trying to convert a string into a date format My string looks like
I have a date time as a string, eg. 2010-08-02, I'm trying to convert
I am new to Python 2.6. I have been trying to fetch date datetime
How can I convert a string 08:00 to a DateTime datatype? Im trying to
I'm trying to convert string using Var encode:ansistring; begin encode:=UTF8Encode('اختبار'); showmessage(encode); end; It's working

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.