[time-nuts] Anyone know a portable way of getting seconds since epoch?

Poul-Henning Kamp phk at phk.freebsd.dk
Tue Oct 13 14:10:11 UTC 2009

In message <286f7bad0910130703v6680affbx95905a440000099f at mail.gmail.com>, David
 Kirkby writes:
>I've asked this on comp.unix.shell, but never got a 100% satsifactory
>answer. Perhaps someone here might know.
>Does anyone know how to get the number of seconds since 1/1/1970 on a
>Unix system using the shell - not compiling C code. I can't assume the
>computer has perl, python or a C compiler.

On FreeBSD you can use the strftime facility in date(1):

	$ date +%s


Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

More information about the time-nuts mailing list