[KLUG Members] Subtracting Time

Adam Williams members@kalamazoolinux.org
Wed, 3 Jul 2002 08:40:05 -0400 (EDT)


>Oops!  It occurred to me that I should be able to pass the date/time values 
>to the Oracle database in a sql script and extract the time value from
>the return value.  This should be fairly easy.

Or you can use the date command -

date --date="24June2003 13:01" +%s

displays the specified time in UTC,  since UTC is an integer you can 
add/subtract one UTC from another.  For example,  the result of the above 
command is 1056474060

date --date="24June2003 3:01pm" +%s 

will work too, or

date --date="June 24 2002 3:01pm" +%s

If you just want the month name you can specify the output format

date --date="June 24 2002 3:01pm" +%b
Jun

or something more elaborate

date --date="June 24 2002 3:01pm" +%m-%d-%Y
06-24-2002

Very nice for converting various date input formats into one format.

But I'm not clear on how to convert a UTC in bash back to a human time, as 

$date --date=1023390060 +%m-%d-%Y
date: invalid date `1023390060'

? Anyone know how to tell date that the input time is a UTC?