Format string to datetime


hi all,

below string 

"2015-03-25 18-59-33 pm "

i wan convert below format

mm/dd/yyyy hh:mm:ss am/pm

how can convert this.

i think of using regex format time portion contains - instead of : , apply required format on:

            string datestring = "2015-03-25 18-59-33 pm";             string output = regex.replace(datestring, @"(?<= .*)-", ":");             var date11 = string.format("{0:mm/dd/yyyy hh:mm:ss tt}", datetime.parse(output));             console.writeline(date11);

this return:

03/25/2015 18:59:33 pm


fouad roumieh



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

How to Share webservice object to all user

How to fix error Msg 1801, Level 16, State 3, Line 1