brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: date --debug shows how GNU date understood your date string

Linux
~/tips/tip-date-debug-parse

date --debug -d 'next friday 14:30'

Prints how GNU date parsed a date string, step by step, and warns about questionable input.

GNU date accepts phrases like next friday, and sometimes the answer isn’t the one you expected. Instead of guessing, ask it to explain itself.

date --debug -d 'next friday 14:30'

The help text for --debug says it annotates the parsed date and warns about questionable usage to stderr. With GNU coreutils 9.4 on 1 December 2026 (a Tuesday), the output began like this:

date: parsed day part: next/first Fri (day ordinal=1 number=5)
date: parsed time part: 14:30:00
date: input timezone: system default
...
date: new start date: 'next/first Fri' is '(Y-M-D) 2026-12-04 14:30:00'

It ends with the normal result, Fri Dec 4 14:30:00 UTC 2026. So you see which words became a day, which became a time, which time zone was assumed and what the starting date was. That last part is the one that tends to explain surprises.

It is just as useful for errors. For date --debug -d '2026-13-01' it printed the date as parsed, a note that it used midnight as the starting time, the normalized value (2027-01-01 00:00:00) and a list of possible reasons, such as numeric values overflowing or a missing time zone, before the plain invalid date message.

Caveat: the debug lines go to stderr and the result goes to stdout, so they don’t pollute $(date ...) in a script, but you will see them on screen. And the format of those lines is meant for people. I wouldn’t parse it in a script.

Further reading: GNU coreutils: Date input formats, GNU coreutils: date invocation

More Linux tips notify-send -r "$id" "Backup" "Done" pgrep -af 'sleep 301' smbstatus -L msmtp --serverinfo --tls --tls-certcheck=off --host=smtp.example.com --port=587 smbclient //server/share -U user -Tc backup.tar "*" All Linux tips (283) All topics

Link