Dr. David Kirkby wrote: > If you have a system with the GNU version of date, then > > date -u +%s > > will give the seconds since the Epoch. Unfortunately, it only works with GNU > date, and so will not work on Solaris, HP-UX or no doubt many other Unix > systems. > > The following script should compute this is a portable manner. Here's a few > examples > > On sage.math, where date accepts +%s > > kir...@sage:~$ date -u +%s && ./unixtime > 1260720556 > 1260720556 > > > On an HP-UX system, where date does *not* accept +%s > > bash-2.04$ uname -a > HP-UX hpbox B.11.11 U 9000/785 2016698240 unlimited-user license > bash-2.04$ ./unixtime && date -u +%s > 1260720771 > date: bad format character - s > > On an OpenSolaris system, where date does *not* accept +%s > > bash-3.2$ ./unixtime && date -u +%s > 1260720823 > %s > > > On an IBM server running AIX 6.1, where date does accept +%s > > $ uname -a > AIX client1 1 6 00C6B7C04C00 > $ ./unixtime && date -u +%s > 1260721013 > 1260721013 > > > > For every system I am able to check this on, the following script gives > exactly > the same output as the GNU date command, but in a more portable manner. > > Could a few people check it on their systems.
x86 64-bit Ubuntu Karmic: % sh unixtime.sh && date -u +%s 1260813444 1260813444 Looks good to me. Jason Jason -- To post to this group, send an email to [email protected] To unsubscribe from this group, send an email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
