Microsoft Word's date picker content control (which you can add to a document through the hidden-by-default Developer ribbon) uses date/time formatting strings that are slightly incompatible with DateTime.ToString. For example:

If I use the same format in DateTime.ToString:
DateTime.Parse("11/13/2014 12:00 PM").ToString("M/d/yyyy h:mm am/pm")
The result is "11/13/2014 12:00 a0/p0". The expected result is what Word displays, "11/13/2014 12:00 PM" (yes, PM is capitalized).
Is there a safe way to use a date format extracted from a Word content control to format a date in C#?
There is no
amorpmas a custom date and time format specifiers.You need to use
"tt"custom format specifier which represents the entireAM/PMdesignator of yourCurrentCulture.Your program thinks your
aandpcharacters as a literal string delimiter andmspecifier is for minutes. Since your single digit minute of yourDateTimeis0, youram / pmwill bea0 / p0And remember,
"/"custom format specifier has a special meaning of replace me with current culture or supplied culture date separator. That means if yourCurrentCulture'sDateSeparatoris not/, your result will have your current date separator, not/.