tags 12650 + moreinfo
thanks
Thiago Picharski wrote:
> I'm trying run this command "date -d 12-10-21", but occur the follow
> error, date: invalid date "12-10-21"
> and finalize with error code 1.
What timezone are you in? Almost certainly that timezone experienced
a daylight savings time change and the time you are asking about does
not exist, is invalid. "Spring forward and Fall back." When DST
jumps forward then some times will not exist by act of law, not
technology. Technology says use UTC but people like local time to
change from place to place. :-)
Please read this reference and let us know if it covers your case or
not.
http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-working-right_002e
The basic problem is that when you specify 12-10-21 it means
hours. That is often when DST changes. Better to specify noon
instead which is far from when DST changes.
$ date -d "12-10-21 12:00"
Best would be to work in UTC to avoid DST issues entirely.
$ date -u -d "12-10-21 12:00 UTC"
> Interestingly, when i run "date -d 12-10-20" or "date -d 12-10-22" this
> work fine.
Very likely those dates are valid. Since you didn't say what timezone
you are working in I can't look to see what was happening there.
Bob