Date: Mon, 2 Aug 1999 13:29:27 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Rich cc: djgpp AT delorie DOT com Subject: Re: Printing the PROPER current Date/Time In-Reply-To: <1.5.4.16.19990801222107.337fe474@erie.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sun, 1 Aug 1999, Rich wrote: > time_t secs_now; > > //Copied from LIBC.HLP file. > /* time_t mktime(struct tm *tptr); */ > /* time_t time(time_t *t); */ > /* struct tm *localtime(const time_t *tod); */ > > int main(int argc, char **argv) { > char buf[100]; > > time_now = localtime(&secs_now); > > strftime(buf, 100, "%B %d, %Y", time_now); > > printf("%s\n", buf); > > } > ------------------ > Outputs: > January 01, 1970 > ------------------ > How do I get a PROPER Date/Time (like from the system clock)? You are passing to `localtime' a value of zero, which corresponds to the so-called ``epoch'', January 1, 1970. You need to set the argument of `localtime' to the current time, like this: time_t secs_now = time (NULL); struct tm *time_now = localtime (&secs_now); Then call `strftime' or whatever.