User Tools

Site Tools


time_calculations

This is an old revision of the document!


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"; '

Epoch time on system without GNU date

perl -e 'print time(), "\n" '

Convert from Epoch with perl

perl -e "print scalar(localtime(1268727836))"

Find date for last password change for Linux user

Replace <username> with account in question

passwd -S <username>
<username> PS 2013-02-27 7 90 7 14 (Password set, SHA512 crypt.)
date -d "1 January 1970 + $(grep <username> /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
time_calculations.1365435460.txt.gz · Last modified: 2013/04/08 15:37 by root