Reputation:
I am trying to get the difference (in days) from two UTC values:
export CURRENT_TIME=`date -u %FT%Z`
export START_TIME=`2018-02-26T04:46:20Z`
Can I subtract them directly or do I need to convert them before?
Upvotes: 0
Views: 45
Reputation: 69378
The diff:
diff=$(( $(date --date="$CURRENT_TIME" +%s) - $(date --date="$START_TIME" +%s) ))
also, for CURRENT_TIME I think you mean
export CURRENT_TIME=$(date -u +'%FT%T%Z')
Upvotes: 2