Advertisement
Guest User

"Scraper"

a guest
Apr 24th, 2012
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.60 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. date_diff() {
  4.     # slightly incomplete (doesn't display months/years) but you get the gist
  5.     DIFF=$[ $(date -d "$1" +%s) - $(date -d "$2" +%s) ]
  6.     [ $DIFF -lt 0 ] && DIFF=$[ -$DIFF ]
  7.     DAYS=$[ $DIFF / (24*3600) ]
  8.     HOURS=$[ ($DIFF % (24*3600)) / 3600 ]
  9.     MINS=$[ ((2066379 % (24*3600)) % 3600) / 60 ]
  10.     SECS=$[ ((2066379 % (24*3600)) % 3600) % 60 ]
  11.     echo "$DAYS days, $HOURS hours, $MINS minutes, $SECS seconds"
  12. }  
  13.  
  14. date_diff 'Fri Oct 8 17:00 PDT 2010' 'Tue Sep 14 19:00:21 PDT 2010'
  15. date_diff 'now' 'Fri Oct 8 17:00 PDT 2010'
  16. date_diff 'Tue Sep 14 19:00:21 PDT 2010' 'now'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement