timestamps

All posts tagged timestamps

Here’s how to come up with 978307200 and what this number represents.. the number of seconds in between the years Jan 1st, 1970 and Jan 1st 2001.. which is 31 years + 8 leap year days…so

31 years 365 days 8 leap year days 24 hours in a day 60 minutes in a hour 60 seconds in a minute

((31*365))+8)*24*60*60  = 978307200

So with this info, you can change the unix timestamps into human readable form.

Take your timestamp and add 978307200 to it..

timestamp + 978307200 =

285884884.420929 + 978307200 = 1264192084.42093

Now take 1264192084.42093 and divide this by the # of seconds in a day +25569..

1264192084.42093/86400 + 25569 = 40200.8528289459

Now if you take this 40200.8528289459 and convert this to a date in Excel you will get the timestamp..

40200.8528289459 = Friday, January 22, 2010 20:28:04

In Excel or Libre Office Calc

A2 = unix timestamp

=A2+978307200 = A3

=A3/86400 +25569 = A4

Convert A4 to date …and there you go…

 

Got really tired of not remembering to update the timestamps in the bash header I use.   The way it works is it will look for the words “Last modified: in the first 20 lines of any *.sh scripts I create.   Upon :wq it will auto-update the timestamp at last modified section.    This works great, if you just open your file but make no modifications then it will not update the timestamp.  So if you wonder why it’s not working, try updating the file..  =)

 

Put this in your ~/.vimrc file

” If buffer modified, update any ‘Last modified: ‘ in the first 20 lines.
” ” ‘Last modified: Sun 12 Aug 2012 04:37:51 PM PDT
” ” Restores cursor and window position using save_cursor variable.
function! LastModified()
if &modified
let save_cursor = getpos(“.”)
let n = min([20, line(“$”)])
keepjumps exe ‘1,’ . n . ‘s#^\(.\{,20}Last modified: \).*#\1’.
\ strftime(‘%c’) . ‘#e’
call histdel(‘search’, -1)
call setpos(‘.’, save_cursor)
endif
endfun
autocmd BufWritePre * call LastModified()

:au BufWritePre *.sh exe “norm mz”|exe ‘%s/\(<!– DATE –>\).\{-\}\d\d:\d\d:\d\d/\1’.strftime(“%c”).”/e”|norm `z