Learn 3 simple methods to get Unix timestamps (seconds or milliseconds) in Shell for scripts and Discord. Verify results with our free tool!
Shell scripting is ideal for automation, and getting Unix timestamps is a common task. This guide covers 3 methods to generate timestamps in seconds or milliseconds, perfect for scripts and Discord, with DevUtils’ free tool for validation.
A Unix timestamp counts seconds or milliseconds since January 1, 1970, 00:00:00 UTC. Seconds are 10 digits (e.g., 1694870400
), milliseconds are 13 digits (e.g., 1694870400000
) (Keywords: unix timestamp in seconds or milliseconds).
date
Commanddate +%s
# Output: 1694870400
date +%s%3N
# Output: 1694870400000
bc
for PrecisionFor systems lacking %N
:
echo "$(date +%s) * 1000 + $(date +%N)/1000000" | bc
# Output: 1694870400000
Input Shell timestamps into DevUtils’ Timestamp Converter to create Discord formats:
1694870400
, select F
, get <t:1694870400:F>
。DevUtils’ tool verifies Shell timestamps:
Shell offers versatile timestamp methods, and DevUtils’ free Timestamp Tool ensures accuracy. Try it now to enhance your scripting!