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 -d 'TZ="zone" time' converts a time from another time zone

Linux
~/tips/tip-date-d-tz-in-string

date -d 'TZ="America/New_York" 09:00 2026-12-15'

Reads a time as if it were in another time zone and prints it in your own.

Meetings with people in other time zones always make me do the sum twice. GNU date can do it if you tell it which zone the time is in.

date -d 'TZ="America/New_York" 09:00 2026-12-15'

The GNU manual says you can set a time zone for a single date by starting the date string with TZ="rule". The quotes around the rule have to be there, which is why the whole string goes in single quotes. The manual’s own example reads a time in Paris rules, while the output follows whatever TZ is set for the shell.

On GNU coreutils 9.4, with TZ=Europe/Amsterdam, this printed:

TZ=Europe/Amsterdam date -d 'TZ="America/New_York" 09:00 2026-12-15' +'%F %H:%M %Z'
2026-12-15 15:00 CET

Same command with the date moved to 15 July printed 2026-07-15 15:00 CEST. The zone abbreviation changed from CET to CEST with the date, so there’s no need to hard-code an offset.

Go the other way by changing the outer zone, for example TZ=Asia/Tokyo date -d 'TZ="Europe/Amsterdam" 10:00 2026-12-15'. Add -u to print the result in UTC, which gave 2026-12-15 09:00 UTC for that Amsterdam time.

Caveat: the zone names come from the system’s tz database, so use names like America/New_York. And it comes from the GNU manual, so I wouldn’t assume the date command on another system understands it.

Further reading: GNU coreutils: Specifying time zone rules

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