Get current date and time in various formats. Use whenever you need the current date, time, timestamps, or formatted datetime values for any purpose (logging, file naming, scheduling, comparisons, etc.)
Get current date and time in various formats. Use whenever you need the current date, time, timestamps, or formatted datetime values for any purpose (logging, file naming, scheduling, comparisons, etc.)
datetime - Current Date & Time
Get the current date and time in various formats.
Quick Reference
# Date onlydate +%Y-%m-%d # 2025-01-15date +%Y/%m/%d # 2025/01/15date +%d-%m-%Y # 15-01-2025# Date with timedate +"%Y-%m-%d %H:%M:%S"# 2025-01-15 14:30:45date +"%Y-%m-%dT%H:%M:%S"# 2025-01-15T14:30:45 (ISO 8601)date -u +"%Y-%m-%dT%H:%M:%SZ"# 2025-01-15T14:30:45Z (UTC ISO 8601)# Time onlydate +%H:%M:%S # 14:30:45date +%H:%M # 14:30date +%I:%M%p # 02:30PM (12-hour)# Timestampsdate +%s # 1705329045 (Unix epoch)date +%s%3N # 1705329045123 (milliseconds)# Human readabledate"+%B %d, %Y"# January 15, 2025date"+%A, %B %d, %Y"# Wednesday, January 15, 2025date"+%b %d %Y"# Jan 15 2025# File-safe formats (no colons/spaces)date +%Y%m%d # 20250115date +%Y%m%d_%H%M%S # 20250115_143045date +%Y%m%d-%H%M%S # 20250115-143045