I wrote an intuitive command line script for converting UNIX time to human-readable format and vice versa.
When I need to convert UNIX time, a quick Google search will yield solutions like this:
# Works on Mac OS but not Linux date -r 1624032013 # Works on Linux but not Mac OS date -d @1624032013 # Get current time UNIX timestamp date +%s
I find "-r", "-d", "+%s" hard to remember. So I wrote a PHP script to simplify it. Save it as
/usr/bin/unixtime and this is how I use it:
# Get current UNIX timestamp unixtime # Covert to UNIX time unixtime "2021-12-24 23:59:59" # Convert UNIX time to human readable time unixtime 1624032013 # Get hints on how to use this script unixtime help