===== Epoch time calculations ===== ==== Days since Epoch ==== echo $(date +%s)/86400 | bc echo $(($(date +%s)/86400)) let days=$(date +%s)/86400 ; echo $days ==== Days since Epoch without GNU date ==== If perl is installed: perl -e ' $days=int(time()/86400);print "$days\n"; ' ==== Current Epoch time on system without GNU date ==== perl -e 'print time(), "\n" ' ==== Convert from Epoch to date with GNU date ==== date -d @ Example: date -d @1368023418 Wed May 8 16:30:18 CEST 2013 ==== Convert from Epoch to date with perl ==== perl -e "print scalar(localtime(1268727836))" ==== Convert date to epoch ==== date -d 'Apr 30 14:40:09 2012' +%s ==== Convert date 14 days ago to epoch ==== date -d '14 days ago' +%s ==== Find date for last password change for Linux user ==== Replace with account in question passwd -S PS 2013-02-27 7 90 7 14 (Password set, SHA512 crypt.) date -d "1 January 1970 + $(grep /etc/shadow | awk -F: '{print $3}') days" ===== Convert UTC date/time to local timezone ===== date -d '2012-08-08 16:00 UTC' Wed Aug 8 18:00:00 CEST 2012 date -d '2012-12-08 16:00 UTC' Sat Dec 8 17:00:00 CET 2012 ===== Convert current local time to UTC ===== date --utc Wed Aug 8 12:35:15 UTC 2012