Thursday, 12 February 2009

Unix Time

A rare nerdy post!

At precisely 23:31:30 UTC tomorrow all the Unix internal clocks (assuming they are right!) will be showing 1234567890 :-)


This little piece of perl shows the current number of seconds since the Unix epoch (1 Jan 1970 from which all Unix clocks start their ticks!)

#!/usr/bin/perl
my $clock=scalar time() ;
print "$clock seconds since the epoch \n"

or if you are feeling really really sad ... this bit of C

#include < stdio.h >
#include < time.h >
int main(void) {
time_t currtime;
currtime=time(NULL) ;
printf("%d seconds since the epoch\n",currtime);
return 0 ;
}

(Hat tip - Chris!)

No comments: