我如何获得bash下两个日期之间的差额 [英] How do I get the difference between two dates under bash
本文介绍了我如何获得bash下两个日期之间的差额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
确切地说是问题所在.我想从20120203中减去说20120115,得到19作为答案.在shell脚本中实现此目的的最佳方法是什么?
Exactly as the question sounds. I want to subtract say 20120115 from 20120203 and get 19 as the answer. What is the best way to implement this in a shell script?
推荐答案
let DIFF=(`date +%s -d 20120203`-`date +%s -d 20120115`)/86400
echo $DIFF
这篇关于我如何获得bash下两个日期之间的差额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文