Are there any functions built in C to display the current time and date, and if there is could someone display its syntax
Thanks.....

Recommended Answers

All 6 Replies

yes, C is full chock full of time functions. just check out the standard <time.h> library

Yea I know but could u give me an example as to how you would display to the screen.
Ex: The current date is 07/04/210.

Yea I know but

Well, if you knew they were there, then why did you ask if there were any functions?


how you would display to the screen. Ex: The current date is 07/04/210.

um, okay...

printf("Ex: The current date is 07/04/210.");

lol no, I mean the use of some function to retrieve the date from the host computer internal system and display it to the screen

man, you're starting to sound helpless. the link i gave you gives every single time.h function and prototype. a basic search will find examples such as this:

/* localtime example */
#include <stdio.h>
#include <time.h>

int main ()
{
  time_t rawtime;
  struct tm * timeinfo;

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
  printf ( "Current local time and date: %s", asctime (timeinfo) );
  
  return 0;
}

Sorry to sound so help less but I was jus clueless there anyways thanks man

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.