delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/05/06/02:21:00

Date: Sun, 6 May 2001 09:21:42 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Rafal Maj <maj_rafal AT poczta DOT onet DOT pl>
cc: djgpp AT delorie DOT com
Subject: Re: Date in seconds
In-Reply-To: <9d1mlr$i8j$1@info.cyf-kr.edu.pl>
Message-ID: <Pine.SUN.3.91.1010506092122.4974H-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sat, 5 May 2001, Rafal Maj wrote:

> Is there some function that will represent time in seconds ?

Yes, it's called `time', and you already found it.

> If I remember
> correct, ther was some functions return date as seconds after 1972.??.?? or
> something like that.

`time' returns the amount of seconds since 00:00:00 GMT on Jan 1,
1970.

> I have found function time()... but I have problems with it:
>   printf("Time is %d\n", time(0));
> This won't compile in C++ and will in C. Why ? How to compile in C++ ?

What were the compiler error messages?

Did you include <time.h>?

Also note that `time' returns a time_t object, so C++ might object to
printing it with a %d.  Try %u instead.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019