Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One script I use quite often:

    function unix() {
      if [ $# -gt 0 ]; then
        echo "Arg: $(date -r "$1")"
      fi
      echo "Now: $(date) - $(date +%s)"
    }
Prints the current date as UNIX timestamp. If you provide a UNIX timestamp as arg, it prints the arg as human readable date.


Similarly I have for Linux

    epoch () {
        if [[ -z "${1:-}" ]]
        then
                date +'%s'
        else
                date --date="@${1}"
        fi
    }

    % epoch
    1761245789

    % epoch 1761245789
    Thu Oct 23 11:56:29 PDT 2025




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: