strftime / Date Format String Builder

Build a strftime date format string with a live preview, look up every % directive, and get the equivalent layout for Go, PHP date() and date-fns.

Last updatedHow we build & check our tools
Results will appear here once you enter your values.

How strftime format strings work

strftime ("string format time") comes from the C standard library and is used almost unchanged by Python's datetime.strftime, Ruby's Time#strftime, PHP's deprecated strftime(), Perl's POSIX module and the Unix date +FORMAT command. A format string mixes literal text with directives that start with %: %Y-%m-%d becomes 2026-03-05 and %A, %B %e becomes Thursday, March 5.

The preview uses the C locale (English names, %c as Thu Mar 5 14:07:09 2026). The date and time you enter are used as-is, and the UTC offset menu supplies %z and %Z, so the preview never depends on your computer's time zone. Directives that are not defined, such as %Q, are shown unchanged and flagged; Python passes unknown directives through on most platforms, but some C libraries print nothing or crash.

The directives people get wrong

  • %m vs %M. Lowercase m is the month; uppercase M is the minute. %Y-%M-%d produces dates like 2026-07-05 for March.
  • %I without %p. The 12-hour clock needs an AM/PM marker, and midnight is 12, not 00.
  • %y drops the century, so 1999 and 2099 both print 99. Avoid it in anything sortable or stored.
  • %U, %W and %V are three different week numbers. %U counts Sunday-started weeks and %W Monday-started weeks, both starting at week 00 before the first Sunday or Monday. %V is the ISO 8601 week, where week 1 contains the first Thursday; pair it with %G, not %Y. January 1, 2027 is in ISO week 53 of 2026, so %Y-W%V prints the wrong year for it.
  • %j is 1-based (001–366); PHP's z is 0-based, which is why no PHP equivalent is shown.
  • %f (microseconds) and %e are not in C89 and fail on some platforms; %-d style no-padding flags work on glibc and macOS but not on Windows, which uses %#d.

Translating to Go, PHP and date-fns

Other ecosystems use different systems, and the tool converts the whole string for you:

strftimeGo layoutPHP date()date-fns
%Y-%m-%d %H:%M:%S2006-01-02 15:04:05Y-m-d H:i:syyyy-MM-dd HH:mm:ss

Go formats by example: you write the reference time Mon Jan 2 15:04:05 MST 2006 the way you want it to look. Fractional seconds must follow a period (05.000000), and Go has no layout for weekday numbers or week-of-year, so those are flagged.

PHP uses single letters, so literal letters must be escaped with a backslash; the translation adds the escapes (at becomes \a\t).

date-fns, Java's DateTimeFormatter, Moment's newer tokens and ICU all follow Unicode LDML patterns, where literal text is wrapped in single quotes and YYYY means week-based year, a common source of bugs in late December. The translation always uses yyyy. date-fns also refuses DDD (day of year) unless you pass { useAdditionalDayOfYearTokens: true } to format.

Frequently Asked Questions

Common questions about the strftime / Date Format String Builder

Use %Y-%m-%dT%H:%M:%S%z, which prints 2026-03-05T14:07:09+0000. Python's %z has no colon; for the colon form (+00:00) call isoformat() instead, or use %:z on Python 3.12+ and GNU date.
From the same team

Turn your GPU into an OpenAI-compatible API endpoint

Wide Area AI routes your LLM API calls to your own hardware over a Cloudflare Tunnel — free local inference with edge caching and automatic cloud failover. Works with any OpenAI SDK.

Start routing — free

Sources & References

datetime: strftime() and strptime() Format Codes

Python directive meanings, %f, %U/%W and ISO %G/%u/%V

strftime(3) Linux manual page

C/POSIX directives including %e, %C, %j and composites %c, %D, %F, %T

Package time: constants (layouts)

Go reference-time layout elements

DateTimeInterface::format

PHP date() format characters and escaping

format

Unicode LDML tokens used by date-fns