1. Home
  2. Developer tools
  3. strftime Builder

strftime Builder

Type a pattern, pick a date and zone, and see what strftime produces. A table explains every directive used, and a list of all of them lets you add codes with a click.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use strftime Builder

  1. Type a pattern or choose a preset.
  2. Pick the date and the time zone.
  3. Read the result and the explanation of each directive.

Features

  • All common POSIX directives plus GNU flags - _ 0 ^
  • ISO week and year directives
  • Local, UTC, fixed offset or named time zone
  • Explains each directive in your pattern
  • Presets for ISO, log and US formats
  • Reports directives it does not know

Supported formats

Input

  • Pattern
  • Date

You get

  • Formatted date

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the strftime Builder is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Names of days and months are in English whatever the language of your device.
  • Some directives behave differently across C libraries, for example %-d on Windows, and the %Z name comes from the browser, so some zones appear as GMT+9 instead of JST.

Guide

Building date format strings with strftime directives

The strftime function formats a date and time from a pattern full of percent codes: %Y for the year, %m for the month, %H for the hour. It was born in the C library and is now found in Python, Ruby, PHP, the Unix date command and many other tools, with small differences between them. This page lets you try a pattern against a real date, see what each directive contributed and pick up the extras that people forget.

How a pattern is read

Everything that is not a percent sign is copied through. A percent sign followed by a letter is a directive, replaced by the matching part of the date. %Y is the four-digit year, %y the two-digit one, %m the month number from 01 to 12, %d the day from 01 to 31, %H the 24-hour hour, %I the 12-hour hour with %p for AM or PM, %M the minute and %S the second. %A and %B give the full weekday and month names, %a and %b the short ones. A doubled %% produces a literal percent sign.

Flags and padding

GNU libc and the tools built on it allow a flag between the percent sign and the letter. A hyphen removes padding, so %-d gives 5 and not 05. An underscore pads with a space, %_d giving “ 5”, and a zero forces zero padding. A caret writes the result in upper case, so %^a gives FRI. These flags are not part of the C standard, so portable programs avoid them or check the platform, but they are widely useful in shell scripts and Python on Linux and macOS.

Weeks and the ISO year

Week numbers are a common trap. %U numbers weeks from the first Sunday, %W from the first Monday, and %V follows ISO 8601 where week 1 is the week with the first Thursday of the year. Because the ISO week can belong to the previous or next calendar year, there is a matching year, %G. Use %G only with %V; mixing %Y with %V labels 29 December 2025 as 2025-W01, although that day belongs to week 1 of 2026. The pattern %G-W%V-%u gives the ISO week date.

Time zones

Choose the device’s zone, UTC, a fixed offset such as +05:30, or a named zone such as Asia/Tokyo. %z prints the numeric offset, for example +0000 or +0900. %Z prints a zone name, which the browser supplies; for some zones that is an abbreviation such as UTC and for others a form like GMT+9 rather than JST, because abbreviations are not standardised. Prefer %z in machine-readable output.

A worked example

For the instant 2026-10-30 14:05:09 UTC, the ISO 8601 preset %Y-%m-%dT%H:%M:%S%z gives 2026-10-30T14:05:09+0000. The log preset %d/%b/%Y:%H:%M:%S %z gives 30/Oct/2026:14:05:09 +0000, as in web server access logs. %A, %B %-d, %Y gives Friday, October 30, 2026, and the US pattern %m/%d/%Y %I:%M %p gives 10/30/2026 02:05 PM. The week date %G-W%V-%u gives 2026-W44-5, and in Tokyo, %Y-%m-%d %H:%M %Z gives 2026-10-30 23:05 GMT+9.

Limits

The page models the directives of POSIX with the GNU flags. Names of days and months are always in English, whatever the language of your device. Some languages add their own directives, for example Python’s %f for microseconds or Ruby’s %L for milliseconds; check the documentation of your language for those. The result is formatted in the browser from the date you give, so it matches your code only if the code uses the same zone.

Checked against the current version of the strftime Builder on .

Frequently asked questions

Why does %-d work on my laptop but fail on a Windows build server?

The hyphen flag is a GNU extension, found in glibc, Python on Linux and macOS, and Ruby, but the C runtime on Windows does not support it. There the equivalent is %#d. For code that must run on both, format the day with a function of the language or strip the zero afterwards.

Which directive gives the week number, and are all week numbers the same?

There are three schemes. %U counts weeks starting on Sunday, %W counts weeks starting on Monday, and %V is the ISO 8601 week, where weeks start on Monday and week 1 contains the first Thursday. Dates at the turn of the year can fall in different weeks under each.

What does %-d do?

The hyphen flag removes padding, so the 5th of the month prints as 5 and not 05. It works in GNU date and Python on Linux and macOS, but not in the Windows C library.

What is the difference between %Y and %G?

%Y is the calendar year; %G is the ISO week-numbering year, which differs in the first and last days of a year. Use %G only together with %V.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.