Skip to main content

How to Print the Current Date in Your Own Format with date in the Terminal

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

date prints the current date and time, and a format that starts with + makes it print them your way: 2026-12-03, 16:05:32, or Thu, 03 Dec 2026 16:05:30 GMT, the date format HTTP prefers. Each % code in the format stands for one part of the date.

This guide builds four formats, with real output from zsh 5.9 and bash 3.2 on macOS. Every command uses -u, so the time is in UTC and the same wherever you run it.

Syntax​

Syntax
date -u '+<format>'
PartWhat it means
-uUse UTC instead of your computer's time zone
+Says that what follows is a format
<format>Text with % codes in it. Each code becomes one part of the date, and everything else is printed as it is
'...'Single quotes keep the whole format together as one piece, spaces included

The macOS manual page, man date, describes the +: An operand with a leading plus (‘+’) sign signals a user-defined format string which specifies the format in which to display the date and time. The codes are listed in man strftime. These are the ones this guide uses:

CodeReplaced byExample
%aThe weekday, shortThu
%AThe weekday, in fullThursday
%dThe day of the month, 01 to 3103
%bThe month, shortDec
%BThe month, in fullDecember
%mThe month as a number, 01 to 1212
%YThe year with the century2026
%HThe hour on a 24-hour clock, 00 to 2316
%MThe minute, 00 to 5905
%SThe second, 00 to 6030

The Example​

You print the date and time in UTC five ways: in date's own format, as an HTTP date, as a date, as a time, and inside a sentence.

Step 1: Print the Date in UTC​

Terminal
date -u
Output
Thu Dec 3 16:05:29 UTC 2026

That's date's own format. The manual describes -u as Display or set the date in UTC (Coordinated Universal) time. and says what happens without it: By default date displays the time in the time zone described by /etc/localtime or the TZ environment variable.

Step 2: Print It in Your Own Format​

Terminal
date -u '+%a, %d %b %Y %H:%M:%S GMT'

macOS-style terminal window titled Terminal with the command date -u '+%a, %d %b %Y %H:%M:%S GMT', a format made of weekday, day, month, year and time codes followed by the text GMT.

Output
Thu, 03 Dec 2026 16:05:30 GMT

date replaced each code with its part of the date and copied the rest, the comma, the spaces, the colons and the word GMT, exactly as written. The result has the same shape as the example in RFC 9110, the HTTP standard: Sun, 06 Nov 1994 08:49:37 GMT is An example of the preferred format. The standard also says An HTTP-date value represents time as an instance of Coordinated Universal Time (UTC). That's why the command needs -u: the GMT at the end is only true for a time in UTC.

Step 3: Try Other Formats​

A date, a time, and a sentence with the full names:

Terminal
date -u '+%Y-%m-%d'
date -u '+%H:%M:%S'
date -u '+Today is %A, %d %B %Y.'
Output
2026-12-03
16:05:32
Today is Thursday, 03 December 2026.

macOS-style terminal window titled Terminal showing a real zsh session: date -u, then the HTTP date format, an ISO date 2026-12-03, a time 16:05:32 and the sentence Today is Thursday, 03 December 2026.

In the sentence, everything that isn't a code, Today is and the final full stop included, came out as typed. bash printed the same formats, with its own seconds.

Common Mistakes​

MistakeWhat happensDo this instead
No +: date -u '%Y-%m-%d'date: illegal time format, then the command's usage, and exit status 1Start the format with +
No quotes around a format with spaces: date -u +%a, %d %b %YThe same date: illegal time formatPut the whole format in single quotes
%m for the minutes: date -u '+%H:%m'It printed 16:12, the hour and the month, while '+%H:%M' printed 16:05%M is the minute, %m is the month

The first two have the same cause. The manual: If an operand does not have a leading plus sign, it is interpreted as a value for setting the system's notion of the current date and time. Without quotes, the spaces split the format into four pieces, and %d, %b and %Y don't start with a plus. Neither piece of text is a time date can read, and both runs ended with exit status 1. The manual: The date utility exits 0 on success, 1 if unable to set the date, and 2 if able to set the local date, but unable to set it globally.

FAQ​

Is there a ready-made format for this?​

Close to it. date -u -R printed Thu, 03 Dec 2026 16:05:50 +0000. The manual: Use RFC 2822 date and time output format. It ends in +0000, not GMT, so for the format in Step 2, write it out yourself.

Why did %y print 26?​

Lowercase %y is the year without the century. man strftime: is replaced by the year without century as a decimal number (00-99). Use %Y for 2026.

Will the day and month names always be in English?​

No. man strftime says %a is replaced by national representation of the abbreviated weekday name, so the names follow the language settings. With LC_ALL=de_DE.UTF-8 in front, German, date -u '+%a, %d %b' printed Do., 03 Dez.. With LC_ALL=C in front, it printed Thu, 03 Dec.

Conclusion​

date -u '+%a, %d %b %Y %H:%M:%S GMT' printed Thu, 03 Dec 2026 16:05:30 GMT, and '+%Y-%m-%d' printed 2026-12-03. Start every format with +, keep it in single quotes, and tell %m, the month, from %M, the minute.

Additional Resources​