C# custom format to C / POSIX strftime.

13 of 20 fields map cleanly; 7 have no C / POSIX strftime token.

C / POSIX strftime

%Y-%m-%d %H:%M

Reference · Mon, Jan 2 2006, 3:04:05 PM MST

2006-01-02 15:04

2006-01-02 15:04

Right now, your zone

Both sides render the same instant — the translation is faithful.

C# custom formatC / POSIX strftimeFieldExample
yyyy%YFour-digit year2006
yy%yTwo-digit year06
Mno tokenMonth number1
MM%mMonth number, padded01
MMM%bMonth name, abbreviatedJan
MMMM%BMonth name, fullJanuary
dno tokenDay of month2
dd%dDay of month, padded02
ddd%aWeekday, abbreviatedMon
dddd%AWeekday, fullMonday
Hno tokenHour, 24-hour clock15
HH%HHour, 24-hour clock, padded15
hno tokenHour, 12-hour clock3
hh%IHour, 12-hour clock, padded03
tt%pAM/PM markerPM
mm%MMinute, padded04
ss%SSecond, padded05
fffno tokenFractional seconds000
zzzno tokenUTC offset, extended-07:00
gno tokenEraAD