How to Convert Epoch to Date in Bash (With Example)


Often you may want to convert an epoch timestamp to a human readable date format in Bash.

You can use the following syntax to do so:

date -d @1717080469

This particular example will convert the epoch timestamp 1717080469 to a human readable date with a date and time.

Note: We use the -d operator to specify that we would like to display the date described by the string that follows it. Without this operator, the date command would simply return the current date and time.

The following example shows how to use this syntax in practice.

Example: How to Convert Epoch to Date in Bash

Suppose we would like to convert the epoch timestamp 1717080469 to a human readable date.

We can use the following syntax to do so:

date -d @1717080469

The following screenshot shows how to use this syntax in practice:

Bash convert epoch to date

We can see that the epoch timestamp 1717080469 has been converted to a date represented as:

  • Thu May 30 10:47:49 EDT 2024

Also note that we can use the + operator to format the date in any way that we would like.

For example, we can use the following syntax to convert the epoch timestamp to a date and then format it to be shown as mm/dd/yyyy:

date -d @1717080469 +'%m/%d/%Y'

The following screenshot shows how to use this syntax in practice:

Bash convert epoch to date with specific format

Notice that we’ve successfully converted the epoch 1717080469 to a date and then formatted it to be shown as 05/30/2024.

Note: Feel free to use whatever format you would like by using the + operator.

Related Tutorials

The following tutorials explain how to perform other common tasks in Bash:

How to Convert Timestamp to Date in Bash
How to Calculate Date Difference in Bash
How to Compare Dates in Bash

Leave a Reply