Click here to Skip to main content
13,738,488 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I am fetching some data from some API, the date am getting is as below: {dd/MM/yyyy hh:mm:ss} "6/15/2014 6:45:00"

Is there anyway I can directly convert it to date time ? Please guide.. Thanks in advance.


What I have tried:

I tried .ToString(""), Convert.ToDateTime() and Parse/ExactPare but nothing work. 
Posted 10-Aug-18 1:16am
Updated 10-Aug-18 2:06am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try:
string date = "6/15/2014 6:45:00";
DateTime dt;
if (DateTime.TryParseExact(date, "M/d/yyyy h:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
    {
    Console.WriteLine(dt);
    }
  Permalink  
Comments
rooohit 10-Aug-18 8:25am
   
thanks a lot...
OriginalGriff 10-Aug-18 8:27am
   
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.180920.1 | Last Updated 10 Aug 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100