.net - Date format with AM/PM designator is not correctly parse -


i'm using code convert string date.

dim outputdate date ' have tried datetime dim inputstringdate string = "january 14, 2013 pm" dim dateformat string = "mmmm dd, yyyy tt"       isvaliddate = date.tryparseexact(inputstringdate, dateformat, new cultureinfo("en-us"), _                                       globalization.datetimestyles.none, outputdate)     ' isvaliddate = true outputdate.tostring(dateformat) 'january 14, 2013 

the issue "tt" not recognize. input text "pm" (january 14, 2013 pm) after parsing date , applying format got "am" (january 14, 2013 am).

the time of outputdate 00:00:00, think should pm default time 12:00:00.

environment: .net 2.0
dtinfo.pmdesignator = pm
dtinfo.amdesignator = am

thanks help

overview

when trying parse date string am/pm designator (tt) without time (hh:mm), example “january 14, 2013 pm” (mmmm dd, yyyy tt), seems .net framework 2 successful parse ignore am/pm portion setting time default, midnight (00:00). solution giving time e.g. “hh:mm tt” or “hh:mm”.
using .net framework 4 in same scenario, parsing date string without time fail; because .net 4 require time , am/pm designator (hh:mm tt), or use of 24 format (hh:mm). @dave michener (please review comment)

so in .net 4
mmmm dd, yyyy tt --> fails
mmmm dd, yyyy hh:mm --> fails
mmmm dd, yyyy hh:mm tt --> works
mmmm dd, yyyy hh:mm --> works

correct me if i'm wrong there's no such thing 'pm default time'. there's default time value if don't specify time @ ("00:00:00"), if don't specify minutes , seconds ("hh:00:00") or if don't specify seconds ("hh:mm:00"). if want pm need give time work with. wouldn't know talking if fed "am" input either, happens default uses when understands format can't unambiguously parse time looks understands.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -