Click here to Skip to main content
13,831,542 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. 
Updated 10-Aug-18 3:06am

1 solution

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

Solution 1

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))
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
Web06 | 2.8.190114.1 | Last Updated 10 Aug 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

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