|
2011-02-17
, 09:27
|
Posts: 840 |
Thanked: 823 times |
Joined on Nov 2009
|
#2
|
Hello,
is there any "days since" or "time since" or "time counter" application available?
thanks
Larry
#!/bin/bash CURRENT=$(date -u '+%F %T.%N %Z') PAST=$(date -u -d"$1" '+%F %T.%N %Z') MPHR=60 HPD=24 secondsdiff () { printf '%s' $(( $(date -u -d"$CURRENT" +%s) - $(date -u -d"$PAST" +%s))) } DAYS=$(( $(secondsdiff) / $MPHR / $MPHR / $HPD )) CURRENT=$(date -d"$CURRENT -$DAYS days" '+%F %T.%N %Z') HOURS=$(( $(secondsdiff) / $MPHR / $MPHR )) CURRENT=$(date -d"$CURRENT -$HOURS hours" '+%F %T.%N %Z') MINUTES=$(( $(secondsdiff) / $MPHR )) CURRENT=$(date -d"$CURRENT -$MINUTES minutes" '+%F %T.%N %Z') printf '%s days, %s hours, ' "$DAYS" "$HOURS" printf '%s minutes, and %s seconds ' "$MINUTES" "$(secondsdiff)" printf 'since %s!\n\n' "$PAST"
|
2011-02-17
, 11:25
|
|
Posts: 2,121 |
Thanked: 1,540 times |
Joined on Mar 2008
@ Oxford, UK
|
#3
|
|
2011-02-17
, 11:59
|
Posts: 411 |
Thanked: 195 times |
Joined on May 2010
@ Cambridge, UK
|
#4
|
|
2011-02-17
, 13:34
|
Posts: 2,802 |
Thanked: 4,491 times |
Joined on Nov 2007
|
#5
|
expr \( $(date +%s) - $(date +%s -d $PAST) \) / 86400
The Following User Says Thank You to lma For This Useful Post: | ||
|
2011-02-17
, 13:52
|
Posts: 136 |
Thanked: 115 times |
Joined on Jul 2010
@ Greece
|
#6
|
|
2011-02-18
, 05:46
|
Posts: 35 |
Thanked: 1 time |
Joined on Dec 2009
|
#7
|
|
2011-02-18
, 06:18
|
Posts: 145 |
Thanked: 54 times |
Joined on Feb 2011
@ Finland
|
#8
|
|
2011-02-19
, 13:34
|
Posts: 35 |
Thanked: 1 time |
Joined on Dec 2009
|
#9
|
is there any "days since" or "time since" or "time counter" application available?
thanks
Larry