[vox-tech] feeding a bash variable to date?

Bill Broadley bill at broadley.org
Sat Nov 7 11:27:50 PST 2009


Gandalf Parker wrote:
> this works
>   date -d '2009-11-06 17:07:54 32 hours'
> 
> this works
> offset="'2009-11-06 17:07:54 32 hours'"
> 
> This does not work
> date -d $offset

How about:
$ offset="2009-11-06 17:07:54 32 hours"
$ date -d "$offset"
Sun Nov  8 01:07:54 PST 2009

BTW, epoch time is easy, just ask date for the current time and add 32*60*60
to it.  Not like you have to calculate it from 1970.


More information about the vox-tech mailing list