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

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'