My datetime
is in this format 2017-01-15T21:00-07:00
so I am parsing it out like so
string ADT = Convert.ToString(timestamp.DateOrTimestamp);
int index = ADT.IndexOf("T");
string FADT = (index > 0 ? ADT.Substring(0, index) : "");
DateTime dtFADT = DateTime.ParseExact(FADT, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
string ADT1 = ADT.Split('T', '-')[3];
Console.WriteLine("{0}: {1}", timestamp.Type, dtFADT.ToString("MM/dd/yyyy") + " " + String.Format("{0:h:mm t}", ADT1));
Which will write to the console: Delivery: 01/15/2017 09:00:00
Why does the String.Format()
not add in the AM/PM to my time?