Date format conversion

Hi All,

Can someone please let me know how can i convert the date format in unix as follow:

From: 24 Oct 2011
i.e $(date +'%d %b %Y')


To: 111024
i.e $(date +%y%m%d)

Thanks in advance

echo '24 Oct 2011' | nawk -f david.awk
david.awk

BEGIN {
 mon="JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC"
  monN=split(mon, monA, "|");
  for(i=1; i<=monN; i++) {
     monA[monA]=i;
     delete monA;
  }
}
{
     print substr($3,3) sprintf("%02d",monA[toupper($2)]) sprintf("%02d", $1)
}

if your date command supports -d option.

date -d "24 Oct 2011"  +%y%m%d
111024

If not GNU date ..

$ echo "24 Oct 2011" | 
   nawk ' { months="  JanFebMarAprMayJunJulAugSepOctNovDec";date=$1;month=index(months,substr($2,1,3))/3;
   year=$3; printf("%s%02s%02s\n",year,month,date)}'
20111024