Hi All,

I am trying to convert epoch time to local time using a bash script. The problem is, it does not accept variables. If I run the following command:

date -d '1970-01-01 1217304400 sec GMT' +"%Y-%m-%d %T"

The local time is returned in the specified format (2008-07-29 00:06:40). The problem I have is that I need to pass the epoch date as a variable because I have a ton of them. Here is what I am attempting to run (TIMEU=1217304400):

CMD="date -d '1970-01-01 ${TIMEU} sec GMT' +\"%Y-%m-%d %T\""
echo $CMD
DSTMP=`$CMD`

The echo displays the appropriate command:
date -d '1970-01-01 1217304400 sec GMT' +"%Y-%m-%d %T"

But I get the following error:
date: too many non-option arguments: sec ...
Try `date --help' for more information.

If I run the command that was echo'd to the screen, it runs properly.

Any help would be greatly appreciated.

Thanks!
RD