Thursday, 15 August 2013

c# - Parsing different time formats into short time format -


I am trying to parse different time formats and parse it in the "5:00 AM" short time format.

I want to be able to understand these different formats. "5:00" at 5:00 pm, "05:00", "05:00 pm", "5 pm" "5:00 am," "05 pm," "05:00 pm," " 5 "," 13 "/ P>

I currently have

  string [] format = {" hh ","% h ", @" h \: mm " , @ "Hh \: mm", @ "d \ .hh \: mm \: ss", "fffff", "hhmm"}; Timespain newtime = new timespan (); If (timespace.TrappersExact (TSTExtime. Text, format, blank, new time)) {txtEndTime.Text = Parser.GetDateTime (newtime). ToShortTimeString (); }    

I think it's really like

  string [] format = {"hh", "hhh", "hht", "% h", "% hesitation", "% h tt", @ "h \: mm", @ "H \: MMTT" @ "H \: MM TT", @ "HH \: mm", @ "HH \: MMTT", @ "HH \: MM TT", @ "D \ .HH: mm \ "SS \", @ "D \ .hh \: mm \: sstt", @ "d \ .hh \: mm \: ss tt", "fffff", "hhmm", "hhmmtt", "hhmm tt" }; Datetime NewDet = New DateTime (); If (DateTime.TrippersExact (textartime.text, format, blank, datetime-style, none, no new date)) {txtStartTime.Text = newDate.ToShortTimeString (); }    

No comments:

Post a Comment