Click here to Skip to main content
16,019,273 members
Please Sign up or sign in to vote.
1.67/5 (2 votes)
See more:
Hello Friends


I want to convert string into date time

i have string "07/10/2012 12:00:00"


and want in datetime formate



2012-10-07 12:00


Plz Help me

Thanks
Posted

Look at DateTime.Parse[^], DateTime.TryParse[^], DateTime.ParseExact[^] and DateTime.TryParseExact[^] - all of them convert strings to DateTime values.
 
Share this answer
 
Try this:
C#
// String to DateTime
 String MyString;
 MyString = "07/10/2012 12:00:00";

 DateTime MyDateTime;
 MyDateTime = new DateTime();
 MyDateTime = DateTime.ParseExact(MyString, "yyyy-MM-dd HH:mm", null);
 
Share this answer
 
Comments
Manas Bhardwaj 10-Jul-12 6:30am    
Correct +5!
Prasad_Kulkarni 10-Jul-12 6:34am    
Thank you Manas!
see below link..

this link will help you..
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900