Strftime Format Builder — Visual Date Format String Editor

Click strftime tokens (%Y, %m, %d, %H, ...) to assemble a format string, see it applied live to the current date, and instantly read the equivalent in Moment.js, date-fns, and Day.js.

Preview against:Mon May 11 2026 18:22:18 GMT+0000 (Coordinated Universal Time)
Year
Month
Day
Hour
Minute / Second
Time zone
Combined
Day of week
2026-05-11 18:22:18
strftime
%Y-%m-%d %H:%M:%S
Moment.js
YYYY-MM-DD HH:mm:ss
date-fns
yyyy-MM-dd HH:mm:ss
Day.js
YYYY-MM-DD HH:mm:ss

What is strftime?

strftime ("string format time") is a C standard library function that turns a date/time value into a formatted string using percent-prefixed tokens — %Y for the year, %m for the month, %H for the hour, and so on. Because every Unix-y language wraps the C runtime, strftime ended up everywhere: Python, Ruby, Perl, PHP, the shell date command, PostgreSQL to_char, and many log formatters.

JavaScript famously has no built-in strftime — you reach for Intl.DateTimeFormat, Moment.js, date-fns, or Day.js. This builder bridges the two worlds: design a format with familiar strftime tokens, see it rendered live, then copy the equivalent in whichever JavaScript library your codebase uses.

How to build a date format string — 4 steps

  1. Pick tokens from the grid. Year, month, day, hour, minute, AM/PM, time zone, ISO week. Clicking appends to the format.
  2. Add literal text. Type dashes, slashes, spaces, or words directly. %% emits a literal percent.
  3. Verify the live preview. The preview is the format applied to the current moment. Tweak until it looks right.
  4. Copy your translation. The bottom panel mirrors the format in Moment.js, date-fns, and Day.js syntax — copy whichever your code uses.

Sample input / output

Format:    %Y-%m-%d %H:%M:%S
Preview:   2026-04-30 14:32:11
Moment.js: YYYY-MM-DD HH:mm:ss
date-fns:  yyyy-MM-dd HH:mm:ss

Format:    %A, %B %d %Y at %I:%M %p
Preview:   Thursday, April 30 2026 at 02:32 PM
Moment.js: dddd, MMMM DD YYYY [at] hh:mm A
date-fns:  EEEE, MMMM dd yyyy [at] hh:mm a

Format:    %FT%T%z   ← ISO 8601 with offset
Preview:   2026-04-30T14:32:11-0700

Click-to-build

40+ strftime tokens grouped by year, month, day, time, zone, and combined shortcuts. One click appends to the format.

Live preview

Every keystroke or token click re-runs the strftime parser on the current date. No need to leave the page to test.

Library translation

Same format string emitted as Moment.js, date-fns, and Day.js syntax — with literal letters auto-bracketed.

Common use cases

  • check_circleDesigning a log timestamp format (e.g. %Y-%m-%dT%H:%M:%S%z) and verifying it renders correctly
  • check_circlePorting a Python strftime string to a JavaScript codebase that uses date-fns or Day.js
  • check_circleBuilding a custom filename pattern for backups or rolling log files
  • check_circleGenerating an OPENAI / CRON-style human label like "Friday 2:32 PM"
  • check_circlePicking ISO 8601 (%FT%T%z) vs RFC 2822 vs custom layouts side by side
  • check_circleMatching a database to_char format (PostgreSQL) to your application code
  • check_circleCreating a localized header for invoices, reports, or scheduled emails
  • check_circleTeaching strftime tokens visually instead of pointing engineers at man pages

strftime vs Moment.js vs date-fns — what to pick

strftime is the right pick for shell scripts, log formatters, and any backend already in C, Python, Ruby, or PHP — it is the universal lingua franca. Moment.js is in maintenance mode but still ubiquitous in legacy JavaScript codebases; its YYYY-MM-DD HH:mm:ss tokens read intuitively but the bundle is heavy (~70 KB). date-fns is tree-shakeable, immutable, and the modern default for new TypeScript projects — its tokens look similar to Moment but are case-sensitive and stricter. Day.js is a 2 KB Moment-API drop-in. The translation panel handles the syntactic differences; the choice between them is a function of bundle size and ecosystem fit.

Need other DateTime tools?

Pair the strftime builder with the rest of OpenFormatter's browser-side date and time toolkit.

Frequently Asked Questions

What is strftime?

strftime is "string format time" — a C library function from POSIX that converts a date/time struct into a formatted string using percent-prefixed tokens (%Y, %m, %d, etc). It first appeared in C89 and was inherited by virtually every language that wraps the C runtime: Python (datetime.strftime), Ruby (Time#strftime), Perl, PHP (date), shell (date +"%Y-%m-%d"), PostgreSQL (to_char), and many more.

Is strftime the same in every language?

Mostly, but not exactly. The core tokens (%Y %m %d %H %M %S) are universal. Differences appear at the edges: Python supports %f (microseconds) and %z behaves slightly differently from C; Ruby adds %L (milliseconds); BSD strftime supports %+; GNU adds %N (nanoseconds). When porting a format between languages, run it through the live preview here first, then sanity-check against the target language docs.

How is strftime different from Moment.js format strings?

Moment.js uses repeated letters instead of percent escapes — YYYY for 4-digit year, MM for month, DD for day, HH for 24-hour. There is no leading %. Literal letters in a format must be wrapped in [brackets] (e.g. [Year:] YYYY). The conversion table built into this tool maps %Y→YYYY, %m→MM, %d→DD, and so on, with appropriate bracketing for literals.

What about format tokens like AM/PM?

In strftime, %p emits AM or PM (uppercase, locale-dependent). In Moment.js, A is uppercase AM/PM and a is lowercase. In date-fns, a is the AM/PM marker. To pair AM/PM with 12-hour clock you almost always want %I:%M %p — which becomes hh:mm A in Moment, hh:mm a in date-fns.

How do I escape a literal % in strftime?

Use %% — two percent signs become a single literal percent in the output. So "Battery: 87%%" produces "Battery: 87%". In Moment.js or date-fns there is no special escape because % has no meaning; just include it literally.

What is the difference between %Y and %y?

%Y is the full 4-digit year (2026); %y is the 2-digit year (26). Always prefer %Y for storage and APIs to avoid Y2K-style ambiguity. Use %y only for tight UI labels (date pickers, infographic axes) where the century is obvious from context.

Why is %V different from %U?

%V is the ISO 8601 week number — week 1 is the week containing the first Thursday of the year, weeks start on Monday, and a week always has 7 days. %U (and %W) are non-ISO week-numbering schemes that count weeks starting from the first Sunday or Monday of the year, with a possibly-partial week 0. For business reports and standards-compliant output use %V; %U / %W exist mostly for legacy compatibility.

Can I use the output for date-fns?

Yes — the bottom panel emits a date-fns-compatible string for whatever you build. Pass it directly to format(date, str) from date-fns. Note that date-fns reserves single-letter tokens (D, M, Y) for different meanings than Moment.js, so the converter uses MM/dd/yyyy rather than MM/DD/YYYY. The translation table is built around the date-fns v2+ token set.

Strftime Format Builder — Visual Date Format Editor