Method GetAmOrPmDesignator
GetAmOrPmDesignator(DateTime, IFormatProvider?)
Returns the culture-specific AM or PM designator for the specified date and time value.
public static string GetAmOrPmDesignator(DateTime dt, IFormatProvider? formatProvider = null)
Parameters
dtDateTimeThe date and time value for which to determine the AM or PM designator.
formatProviderIFormatProviderAn optional object that supplies culture-specific formatting information. If null, the current culture is used.
Returns
- string
A string containing the AM or PM designator appropriate for the specified date and time, using any user-defined overrides if present.
Remarks
If a user-defined override for the AM or PM designator is set, it is used in preference to the culture-specific value. If the resulting designator is null, empty, or consists only of white space, the method defaults to "AM" or "PM" based on the time of day. The returned designator is trimmed of any leading or trailing white space.