1848394 Members
2928 Online
104026 Solutions
New Discussion

Re: Date in seconds ??

 
sandro ginnari
Occasional Contributor

Date in seconds ??

Hi,
dose anyone know how to visualize the actual date of the system in seconds?

Thanks
By
4 REPLIES 4
John Palmer
Honored Contributor

Re: Date in seconds ??

Hi,

You can do it with the following C program:-

#include
#include

main(argc,argv)
int argc;
char *argv[];
{
struct tm timeinfo;

printf("%dn",time(NULL));
exit(0);
}

Regards,
John
John Palmer
Honored Contributor

Re: Date in seconds ??

In fact all you need is:-

#include
#include

main(argc,argv)
int argc;
char *argv[];
{
printf("%dn",time(NULL));
exit(0);
}

This prints out the current system time in 'seconds since the epoch', see 'man 2 time' for details.

Regards,
John
Wodisch
Honored Contributor

Re: Date in seconds ??

Hello Sandro,

the easiest way from the shell is to create
an at-job to be started in 1 minute, the
name of the job is the amount of seconds
from 1.1.1970 to the start-time of the job.
HTH,
Wodisch
CITEC HP TEAM
Frequent Advisor

Re: Date in seconds ??

A perl one-liner will achieve this for you:

perl -e '$time = time ; print "$time n"'

This returns the system time in seconds (no. of seconds since 1/1/1970)