Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
date を使って目的の日までの残り日数を計算する - ~fumi/ChangeLog
[go: Go Back, main page]

Prev / Next

2010-02-08 / date を使って目的の日までの残り日数を計算する

- How many days until the end of the year | commandlinefu.com
  http://www.commandlinefu.com/commands/view/4804/how-many-days-until-the-end-of-the-year
から,今年の残り日数.

echo "There are $(($(date +%j -d"Dec 31, $(date +%Y)")-$(date +%j))) left in year $(date +%Y)."
echo "There are $(($(date +%j -d"Dec 31")-$(date +%j))) left in year $(date +%Y)."
echo "There are $(($(date +%j -d"Dec 31")-$(date +%-j))) left in year $(date +%Y)."


1 つめの date の引数を目的の日付にすればよい.

%j は年内通算日数を表す日付フィールド

$ date +%j -d"Dec 31 2010"
365
$ date +%j -d"Dec 31 2008"
366


日付フィールドのハイフンはパディングの制御

$ date +%j -d"Feb 08"
039
$ date +%-j -d"Feb 08"
39


- n 日前の日付けを求める [2005-09-30-6]

comments powered by Disqus