SUMMARY: Number of seconds since 1970

From: Mark Fergusson (MFerg@ddntl.didata.co.za)
Date: Tue Oct 08 1996 - 09:50:08 CDT


Thanks again to all for the great help.

Original question:
The date/time is generally calculated as the number of seconds since
> 1970.
>
> Is there a command/easy way that will give me the number of seconds
> instead of the date as we know it.

Three themes:
1. c script
2. perl -e
3. GNU date

Dave Willard
Ted Nolan
Michael van Dijk
Stanislav Protassov
Stephen Harris:

% cat secs.c
  #include <time.h>
  main()
  {
    time_t t;
    printf("%d\n",time(&t));
  }
  % cc -o secs secs.c
  % secs
  844779475

Joe Shamblin
Peter Marelas
perl -e 'print time;'

Mark Bergman
#! /usr/bin/perl
require "ctime.pl"; # For date calculations.
$seconds=time();
$date=&ctime($seconds);
chop ($date);
$epoch=&ctime(0);
print "$date is $seconds seconds since $epoch\n";

Gerald C. Combs
Try installing GNU date (part of the sh-utils package). It has many
more features than the standard Solaris version, including the ability
to
show seconds. You can find GNU software at
ftp://prep.ai.mit.edu/pub/gnu .

Regards,

=============================================
Mark Fergusson Voice: (+27) - 31 - 838333
Dimension Data Fax: (+27) - 31 - 848525
PO Box 20713 Cellular: 082-4465-118
Durban North Email: mferg@ddntl.didata.co.za
4016
South Africa Web: http://www.didata.co.za
=============================================



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:11 CDT