Mattijn Mattijn - 5 months ago 17
Linux Question

How can I use date command in Linux to read ANSI date

ANSI date numbers starts from January 1st 1601 (day 1).
So how to get the following to work in a bash command in Linux?

I want:

# ANSI / UNIX epoch delta is 134774 days
$ date -ud ‘1601 -01 -01 + 134774 days ’ +%F
1970 -01 -01


But I get

date: invalid date '1601-01-01+134774 days'

Answer

To answer my own question as I meanwhile found this site: http://unix.stackexchange.com/questions/7688/date-years-prior-to-1901-are-treated-as-invalid

It's because I'm on a 32-bit machine.

date -ud '1901-12-14 + 24855 days' +%F

will give

1970-01-01