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

Well, you can do something sneaky like:

$ echo "`date +%s` - (1125 * 24 * 60 *60)" |bc
1194478815
$ date -r 1194478689
Wed, 07 Nov 2007 18:38:09 -0500

Tested on OpenBSD (definitely non gnu based date), and seems to work.

Breaking it down in steps:

  • get the current unixtime (seconds since beginning of unix epoch):
  $ date +%s
  1291679934
  
  • get the number of seconds in 1125 days
  $ echo "1125 * 24 * 60 *60" | bc
  97200000
  
  • subtract one from the other (1291679934 - 97200000) = 1194478815

  • use the new unixtime (1194478815) to print a pretty date

    $ date -r 1194478689
    Wed, 07 Nov 2007 18:38:09 -0500
    
  • As an alternative, on solaris you can do this to print the date*:

    /bin/echo "0t1194478815>Y\n<Y=Y" |adb

* referenced from http://www.sun.com/bigadmin/shellme/

Also, an alternative on Solaris for getting the current timestamp from the date command** is:

/usr/bin/truss /usr/bin/date 2>&1 |  nawk -F= '/^time()/ {gsub(/ /,"",$2);print $2}'

** referenced from http://www.commandlinefu.com/commands/view/7647/unix-timestamp-solaris


Previous answer was far too complicated. FreeBSD/macOS have the -v flag for date, from the MAN page (abbreviated description):

Adjust (i.e., take the current date and display the result of the adjustment; not actually set the date) the second, minute, hour, month day, week day, month or year according to val. If val is preceded with a plus or minus sign, the date is adjusted forwards or backwards according to the remaining string, otherwise the relevant part of the date is set. The date can be adjusted as many times as required using these flags. Flags are processed in the order given.

So for your purpose, date -v1125d will simply do what you need

$ date; date -v-1125d
Thu 19 Oct 2017 11:35:25 EDT
Sat 20 Sep 2014 11:35:25 EDT