Reputation: 2663
In linux bash when I enter date -d "1986-01-01"
it shows error
date: invalid date "1986-01-01"
when date -d "1986-01-02"
it works
when date -d "1987-01-01"
it also works
Why date -d "1986-01-01"
shows error in Linux Bash shell.
I am using Fedora 16
Upvotes: 3
Views: 9742
Reputation: 50024
Nepal changed its timezone at the beginning of 1986. The following table is copied from the tzdata package:
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Kathmandu 5:41:16 - LMT 1920
5:30 - IST 1986
5:45 - NPT # Nepal Time
That means that on Jan 1 1986 the time from 00:00:00 to 00:14:59 is not valid. The following two commands show, that the first day of 1986 started with 00:15:00:
$ TZ=Asia/Kathmandu date -d '1985-12-31 23:59:59' '+%s'
504901799
$ TZ=Asia/Kathmandu date -d '1986-01-01 00:15:00' '+%s'
504901800
So the error message of date
is correct. The date is invalid in this timezone. I am not sure what you are doing with the result of this command. However, you can try to use UTC because all dates are valid and unambiguous in UTC:
$ TZ=UTC date -d '1986-01-01'
Wed Jan 1 00:00:00 UTC 1986
Upvotes: 11
Reputation: 592
I think you are using alphabet "O" in upper case instead of number "0" in the command :)
Upvotes: 0