4 Replies - 73434 Views - Last Post: 22 December 2006 - 10:53 PM Rate Topic: -----

#1 cire_1803  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 20-September 06

Getting Current System Time

Posted 22 December 2006 - 07:50 PM

What must be included in my program to get the current date in my system.

God Bless you all!
Is This A Good Question/Topic? 0

Replies To: Getting Current System Time

#2 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Getting Current System Time

Posted 22 December 2006 - 08:05 PM

View Postcire_1803, on 23 Dec, 2006 - 08:20 AM, said:

What must be included in my program to get the current date in my system.

God Bless you all!

Finding Current Date
Was This Post Helpful? 0
  • +
  • -

#3 cire_1803  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 20-September 06

Re: Getting Current System Time

Posted 22 December 2006 - 09:39 PM

View PostXing, on 22 Dec, 2006 - 08:05 PM, said:

View Postcire_1803, on 23 Dec, 2006 - 08:20 AM, said:

What must be included in my program to get the current date in my system.

God Bless you all!

Finding Current Date


How to convert this code into turbo C code, because i am using C not C++.
Was This Post Helpful? 0
  • +
  • -

#4 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Getting Current System Time

Posted 22 December 2006 - 10:27 PM

View Postcire_1803, on 23 Dec, 2006 - 10:09 AM, said:

How to convert this code into turbo C code, because i am using C not C++.

First get a new compiler or alteast upgrade to Turbo Explorer 2006.

This post has been edited by Xing: 22 December 2006 - 10:28 PM

Was This Post Helpful? 0
  • +
  • -

#20 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Getting Current System Time

Posted 22 December 2006 - 10:53 PM

You need to include TIME.H and then you can use the following.
#include <stdio.h>
#include <time.h>
 
int main ()
{
	char *date;
	
	time_t timer;

	timer=time(NULL);
	
	date = asctime(localtime(&timer));

	printf("Current Date: %s", date);
	
	getchar();
	return 0;
}


You need to call function asctime and localtime to retrieve the time and format it in a readable manner. You create a pointer to type char to store the memory address of the resulting value that is returned. Then you can just display it using the string format specifier.
Was This Post Helpful? 1

Page 1 of 1