# How to convert between dates and seconds since the Unix Epoch in Bash

Today I learned how to convert between dates and seconds since the Unix Epoch using the date command.

# Display the current date

>>> date
Thu 10 Jun 2021 11:24:50 SAST
1
2

# Display the current date as seconds since the Unix Epoch

>>> date +%s
1623317056
1
2

# Display a given date as seconds since the Unix Epoch

>>> date --date="2021-06-01 20:00:00" +%s
1622570400
1
2

# Convert seconds since the Unix Epoch to a user-friendly date

>>> date --date='@2147483647'
Tue 19 Jan 2038 05:14:07 SAST
1
2
Last Updated: 6/10/2021, 9:27:51 AM