cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/01/22:21:57

Date: Sun, 1 Aug 1999 22:21:22 -0400 (EDT)
Message-Id: <1.5.4.16.19990801222107.337fe474@erie.net>
X-Sender: calculs2 AT erie DOT net
X-Mailer: Windows Eudora Light Version 1.5.4 (16)
Mime-Version: 1.0
To: djgpp AT delorie DOT com
From: Rich <calculs2 AT erie DOT net>
Subject: Printing the PROPER current Date/Time
Reply-To: djgpp AT delorie DOT com

/* getting DJGPP to print out a 
   formatted Date/Time string
   (ie, like Borlands lazy strdate() and strtime())
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

struct tm *time_now;
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)?



- Raw text -


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