User Tools

Site Tools


time_calculations

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

time_calculations [2012/08/08 12:37]
root created
time_calculations [2013/09/19 08:17] (current)
root
Line 1: Line 1:
- 
- 
 ===== Epoch time calculations ===== ===== Epoch time calculations =====
  
Line 16: Line 14:
  
  
-==== Epoch time on system without GNU date ====+==== Current ​Epoch time on system without GNU date ====
  
   perl -e 'print time(), "​\n"​ '   perl -e 'print time(), "​\n"​ '
   ​   ​
-==== Convert from Epoch with perl ====+==== Convert from Epoch to date with GNU date  ==== 
 + 
 +  date -d @<EPOCH time> 
 +  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))"​   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 <​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 ​ ===== ===== Convert UTC date/time to local timezone ​ =====
time_calculations.1344429431.txt.gz · Last modified: 2012/08/08 12:37 by root