vb.net - Parse Date Time -


this question has answer here:

below date time format getting api.

mon apr 14 03:31:15 +0000 2014

how can convert dd-mmm-yyyy hh:mm:ss format.

i tried following code:

dim strdate string = "mon apr 14 03:31:15 +0000 2014" dim datet datetime = datetime.parse(strdate) 

i getting following issue:

datetime.parse(strdate) {"string not recognized valid datetime."}

any solution , suggestion appreciated.

you can use datetime.parseexact like:

string str = "mon apr 14 03:31:15 +0000 2014"; datetime dt = datetime.parseexact(str,                             "ddd mmm dd hh:mm:ss zzz yyyy",                             cultureinfo.invariantculture); 

for more information see: custom date , time format strings

for converting parsed date required format do:

string formattedoutput = dt.tostring("dd-mmm-yyyy hh:mm:ss", cultureinfo.invariantculture); 

vb equivalent be:

dim dt datetime = datetime.parseexact(str,                            "ddd mmm dd hh:mm:ss zzz yyyy",                           system.globalization.cultureinfo.invariantculture) dim formattedoutput string = dt.tostring("dd-mmm-yyyy hh:mm:ss", system.globalization.cultureinfo.invariantculture) 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -