↑ ↓ select, Enter open, Esc close

Unix Timestamp Converter

Read the current timestamp, turn a timestamp from a log file into a readable date, or the other way around. With the matching shell commands.

Convert timestamp

Now, seconds

…

Now, milliseconds

…


Timestamp to date

Local
Friday, January 1, 2027 at 00:00:00 UTC
UTC
Friday, January 1, 2027 at 00:00:00 UTC
ISO 8601
2027-01-01T00:00:00.000Z
Relative
…

Date to timestamp

Seconds
…
Milliseconds
…
Matching commands
date +%s
date -d @1798761600
date -u -d @1798761600 "+%Y-%m-%d %H:%M:%S"
date -u -d "2027-01-01 00:00:00" +%s
date -r 1798761600          # macOS and BSD
mysql -e "SELECT FROM_UNIXTIME(1798761600), UNIX_TIMESTAMP('2027-01-01 00:00:00');"

What is a Unix timestamp?

The Unix timestamp (Unix time, epoch time) counts the seconds since January 1, 1970, 00:00:00 UTC. It knows nothing about time zones or daylight saving time, which makes it well suited for storing and comparing points in time. It is only converted to local time for display. JavaScript, Java and many APIs work with milliseconds, so a 13-digit number instead of the usual 10 digits. The converter above detects this automatically.

The most important shell commands

CommandResult
date +%scurrent timestamp in seconds
date +%s%3Ncurrent timestamp in milliseconds (GNU date)
date -d @1798761600timestamp as a local date
date -u -d @1798761600 +%FT%TZtimestamp as ISO 8601 in UTC
date -d "2027-01-01 01:00" +%sdate (local time) to timestamp
date -d "3 days ago" +%stimestamp from three days ago, handy for scripts
date -r 1798761600macOS and BSD: timestamp as a date (there without -d @)

In a crontab the percent sign has to be escaped: date +\%s. More on this in the Cron Generator.

Timestamps in logs

Some logs write raw timestamps, for example Squid, HAProxy statistics, Fail2ban databases or your own scripts. With GNU awk you can make them readable in one go:

awk '{ $1 = strftime("%F %T", $1); print }' access.log

With journalctl you can filter by timestamp directly: journalctl --since "@1798761600". For kernel messages with readable times there is dmesg -T, but the times shown there are inaccurate after a suspend.

MySQL and MariaDB: FROM_UNIXTIME and UNIX_TIMESTAMP

SELECT FROM_UNIXTIME(1798761600);                  -- timestamp to date
SELECT UNIX_TIMESTAMP('2027-01-01 00:00:00');      -- date to timestamp
SELECT * FROM wp_options WHERE option_name LIKE '_transient_timeout_%'
  AND option_value < UNIX_TIMESTAMP();             -- expired transients

Both functions use the time zone of the database session (SELECT @@session.time_zone;), not necessarily that of the server or the application. WordPress, for example, stores transient expiration times as timestamps, but posts as dates in local and UTC time (post_date and post_date_gmt).

The year 2038 problem

If the timestamp is stored as a signed 32-bit integer, it runs out on January 19, 2038 at 03:14:07 UTC (value 2147483647). One second later the number wraps around to negative, back to the year 1901. Current 64-bit systems are not affected, but these are:

  • Columns of type TIMESTAMP in MySQL, whose range ends on January 19, 2038. MariaDB extended the range to the year 2106 on 64-bit systems starting with version 11.5. For dates far in the future, DATETIME is the safe type.
  • Columns of type INT instead of BIGINT for timestamps.
  • Old 32-bit systems, embedded devices and older PHP versions on 32-bit.

Expiration dates of licenses, certificates or long-term subscriptions can cross this limit already today. Test such fields with a date after 2038.

For the websites on your server

Free SEO and PageSpeed check

GENLOC.SEO analyzes any domain for load time, Core Web Vitals and on-page issues and tells you in plain words what is going on. Available in 11 languages.

by GENLOC.NETWORK, the team behind myline.de

Bookmark this page: Press Ctrl + D (Mac: ⌘ + D) to keep the timestamp converter handy for your next look at the logs.

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.