mac-linux date difference

通过脚本判断

#!/bin/bash
os=$(uname -s)
if [[ "$os" == "Linux" ]]; then
date +%Y-%m-%d --date='-1 day -1 year'
elif [[ "$os" == "Darwin" ]]; then
date -v-1d -v-1y +%Y-%m-%d
else
echo "unknown OS"
exit 1
fi

linux date


mac date

date +%Y-%m-%d %H:%M:%S