c# - converting a string to a DateTime format -


i'm trying parse 09/01/2015 00:00:00 format yyyy-mm-ddthh:mm:ssz using following method:

datetime.parseexact("09/01/2015 00:00:00", "yyyy-mm-ddthh:mm:ssz", (iformatprovider)cultureinfo.invariantculture); 

but i'm getting string not recognized valid datetime

can tell me why? believe 09/01/2015 00:00:00 valid datetime format?

from datetime.parseexact

converts specified string representation of date , time datetime equivalent. the format of string representation must match specified format or exception thrown.

in case, not.

i assume 09 part day numbers, can use dd/mm/yyyy hh:mm:ss format instead.

var dt = datetime.parseexact("09/01/2015 00:00:00",                               "dd/mm/yyyy hh:mm:ss",                               cultureinfo.invariantculture); 

since cultureinfo already implements iformatprovider, don't need explicitly cast it.

i don't understand this. means first have correct string , secondly can parseexact(). thought parseexact handle given string...

parseexact not magical method can parse any formatted string suplied. can handle only if string , format matches based on culture settings used.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -