cl date function working differently in Intel and M1 machines I have a shell script to calculate the number of days from a particular date:
echo D$((($(date +%s)-$(date +%s --date &quot;2018-01-01&quot;))/(3600*24)))

On my 2019 MBP (Intel), it works. On my 2020 Mac mini (M1), it doesn't.
The error:
date: illegal time format
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
/usr/local/bin/days: line 1: (1614815225-)/(3600*24): syntax error: operand expected (error token is &quot;)/(3600*24)&quot;)

The man pages are different. On the MBP it's
DATE(1) User Commands DATE(1)

On the Mac mini it's
DATE(1)  BSD General Commands Manual  DATE(1)


What's going on here?
How do I get back the old functionality?
The answer (thanks to a hint by @mmmmmm in the comments) is that in the M1 Mac mini you have to install the gnu coreutils (e.g. via Homebrew), but since the names of some of them overlap with the names of similar (but not identical!) utilities that come with the Mac mini, the system automatically prefixes &quot;g&quot; to any utilities whose names overlap.
Therefore, the problem was solved in my case by changing date to gdate in my code.