[clug] incrementing time

Duncan Roe duncan_roe at acslink.net.au
Wed Nov 5 19:53:27 EST 2003


Hi Boris,

I think the GNU "date" command can do exactly what you want. Look at this:-

 date +%s -d 'Nov 03 07:32:06'
 1067805126

 date +%s -d 'Nov 01 07:32:06'
 1067632326

The man page says:-

 %s     seconds since 1970-01-01 00:00:00 UTC (a nonstandard extension)

Cheers ... Duncan.

On Wed, Nov 05, 2003 at 09:48:24AM +1100, Rousak, Boris wrote:
>
> Greeting all,
>
> This is a bit basic but I am having a mind blank :). I am trying to write a
> script that will check a time stamp written in a file to see if it has been
> an hour since it was made. The stamp is in a format, Nov 03 07:32:06. I am
> using Ksh and the only way possible that I could find (google and all) is to
> convert the date to time since 1970 and do a number comparison. This is
> however a hassle, so the question is: can anyone suggest an easier way to do
> this, awk maybe or something to that effect. I have looked at perl, but that
> requires an extra module download, namely: Date::Manip and this is not an
> option for me. If anyone can hit me with a clue-bat that would be much
> appreciated.
>
> Regards,
> Boris



More information about the linux mailing list