LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-30-2002, 01:35 AM   #1
mr.moto
LQ Newbie
 
Registered: Dec 2001
Posts: 15

Rep: Reputation: 0
Question call for system date in c


In a c program how would you ask linux for the system date ?


thanx
 
Old 09-30-2002, 02:00 AM   #2
mr.moto
LQ Newbie
 
Registered: Dec 2001
Posts: 15

Original Poster
Rep: Reputation: 0
woops I just saw this post ...will give it a try sorry ..

the simplest I can think of is
#include <stdio.h>
main()
{
system("date");
}
--Sarin
 
Old 09-30-2002, 04:23 AM   #3
treebeard
LQ Newbie
 
Registered: Jun 2002
Location: Bucharest, Romania
Distribution: Slackware
Posts: 16

Rep: Reputation: 0
if you want to find the date and use it in your program:
#include <time.h>
int main() {
time_t t;
t = time(NULL);
printf("%d\n", t);
}
here t is the number of seconds since Jan 1, 1970.
also see man time/ man ctime
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
using system call ej25 Programming 9 11-30-2004 12:45 PM
new system call soul2 Linux - General 1 11-03-2004 03:41 PM
Is it possible to use system() and get the return value from the system call newguy21 Programming 1 08-11-2004 02:37 PM
System call dami Linux - General 0 11-18-2003 12:18 PM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 01:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration