On Linux you can convert a date like "2010-10-02" to a unix timestamp in shell script by
date -d "2010-10-02" "+%s"
Since Mac OS does not have the equivalent -d for date. How do you go about converting a date to a unix timestamp in a shell script.
Alternatively you can install GNU date like so:
brew install coreutils
alias date="/usr/local/bin/gdate"
date +%s
1547838127The Mac is "different" because OSX is based on BSD. BSD utilities tend to be conservatively updated, while GNU tools have more enhancements.
Really, if you spend most of your time in Linux, but have a Mac desktop, you probably want to make the Mac work like Linux. Also see: Docker. There's no sense in trying to remember two different sets of options.
man date
on OSX has this exampleWhich I think does what you want.
You can use this for a specific date
Or use whatever format you want.
I used the following on Mac OSX.
This works fine for me on OS X Lion.
date -j -f "%Y-%m-%d" "2010-10-02" "+%s"