From: Westphal, R. W <Ray...@er...> - 2004-01-28 00:07:59
|
Hello AIXers! =20 I was looking through Google AIX group for a Perl script to display epoch time. I found reference to a GNU version of date. =20 To find epoch time: $ perl -e 'print time()' To find time so far ago or in the future via actual passed seconds (86400 seconds a day). Calculating a DAY to be 86400 seconds works=20 most of the time, but there are times it breaks (daylight savings, etc). A more robust applicatoin would be GNU date. $ perl -e 'print $time =3D (localtime (time + (86400 * -1))),"\n";' # ^ -1 day (past) # Pos =3D future # Neg =3D past =20 OR =20 Try GNU date... it does exactly what your asking w/out converting back and forth /pub/gnu/bin/date -d "30 days ago" using different output options (%s say) gives you epoch,=20 as one would expect, the GNU version is much more robust than the base OS version; Is the GNU date included in any of your GNU utilities? =20 Thanks in advance! =20 Ray Westphal. |