Sample Header Ad - 728x90

Calculate the date from 1125 days ago on non-GNU systems?

7 votes
3 answers
6753 views
On the Unix Bash commandline, I want to calculate the date from 1125 days ago using the base operating system (e.g. No Perl or Python). On systems running GNU Date , I can do something like this: ubuntu $ date --date="1125 days ago" Wed Nov 7 15:12:33 PST 2007 FreeBSD or MacOSX systems don't ship with GNU Date, and don't support values like "X days ago". freebsd81 $ date --date="+1125 days ago" date: illegal option -- - I *can* calculate a date from a few days ago on a Mac or FreeBSD system, but this is limited to a few days: # Today is really Dec 6, 2010. 4 days ago it was: macosx $ TZ=GMT+96 date +%Y%m%d 20101202 # But that doesn't work if I want to see the date 8 days ago: macosx $ TZ=GMT+192 date +%Y%m%d 20101206 Can I calculate old dates on non-GNU systems without delving into tools like Perl or Python? Or must I use a more powerful scripting language?
Asked by Stefan Lasiewski (20733 rep)
Dec 6, 2010, 11:24 PM
Last activity: Jan 23, 2019, 09:22 PM