Solaris + display file time stamp [year][month][day]
In Solaris (>= 10) the ls command has the -E option. So your command could be as simple as
ls -E /etc/hosts
or
ls -E /etc/hosts | awk '{print $6}'| sed 's#-##g'
to get the desired result.
A portable way to do it could be:
perl -MPOSIX -le 'print strftime "%Y%m%d", localtime((lstat)[9]) for @ARGV' /etc/hosts