I tried to convert the date pattern in a mac with the below command but it throws an error
date -j -f %m-%d-%Y 02-04-21 "+%Y-%m-%d" date: nonexistent time
I tried to convert the date pattern in a mac with the below command but it throws an error
date -j -f %m-%d-%Y 02-04-21 "+%Y-%m-%d" date: nonexistent time
The %Y
format specifier (in the input format) indicates a 4-digit year (i.e. "2021" instead of just "21"). Either specify a 4-digit year, or use %y
for a 2-digit year:
$ date -j -f %m-%d-%Y 02-04-2021 "+%Y-%m-%d"
2021-02-04
$ date -j -f %m-%d-%y 02-04-21 "+%Y-%m-%d"
2021-02-04