Let me explain you the problem
$ date +%c -d "$d"
Tue 31 Dec 2013 01:13:06 PM CET
$ date +'Today is %F' -d "$d"
Today is 2013-12-31
This solution corresponds to current date.
But I have one variable which stores date other than current date
$Prev_date="Wed Dec 25 06:35:02 EST 2013"
I am looking for solution to read this date as 2013-12-25 and store it in a variable.
I have tried this:
a=`date --date=$Prev_date '+%y/%m/d'`
echo $a
It's giving this error:
date: illegal option -- date=Wed
usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]
date
does not recognize the--date
option. Why don't you use-d "$Prev_date"
like your working example? Anyway, please remember to always include your OS. Are you actually on Unix? If so,date
is very different to the GNUdate
that GNU/Linux uses.