Bash

Format Date Like a Pro

admin by @admin ADMIN
23h ago
May 31, 2026
Public
0 0 up · 0 down Sign in to vote
`date` accepts a format string + optional override of the date being formatted. The +%FT%TZ form gives you ISO-8601 / RFC-3339 in one call.
Bash
Raw
# Current time
date                               # Wed Mar 12 14:25:00 CDT 2025

# ISO 8601 / RFC 3339 (UTC)
date -u +"%Y-%m-%dT%H:%M:%SZ"       # 2025-03-12T19:25:00Z
date -u +"%FT%TZ"                  # same, shorter
date --iso-8601=seconds            # GNU shortcut

# Custom formats
date +"%A %B %d, %Y"               # Wednesday March 12, 2025
date +"%j"                         # day of year (071)
date +"%U"                         # week number (10)

# Format a specific date (GNU date)
date -d "next Friday" +%F          # 2025-03-14
date -d "2 weeks ago" +%F          # 2025-02-26
date -d @1735689600 +%F            # convert epoch → date
Tags

Save your own code snippets

Create a free account and build your private vault. Share publicly whenever you want.