How to get 24 hours Time only while converting datetime using Convent.ToDateTime with the input 24

Posted by Udaysimha under C# on 1/7/2013 | Points: 10 | Views : 1154 | Status : [Member] | Replies : 1
when i am converting a 24 hours string using Convert.ToDateTime is giving only 12 hours format input but i need only 24 hours format time. for example

DateTime dateT=Convert.ToDateTime("01-05-2013 15:44:45");

here i am getting result as 01-05-2013 03:44:45 but i need assign 01-05-2013 15:44:45 to dateT.

Any help would be appreciates.



Posted by: muralikrishnasurap-12704 on: 1/8/2013 [Member] Starter | Points: 25

Please use below code it may solve ur format problem you can pick up any format in this

DateTime dateT = Convert.ToDateTime("01-05-2013 15:44:45");
string[] allFormates = dateT.GetDateTimeFormats();

foreach (string value in allFormates)

Best Regards
Murali Krishna.S

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response