Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
How to determine curreent date and time/
Collapse
This topic is closed.
X
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
Sanchit
#1
How to determine curreent date and time/
Jun 27 '08, 07:28 PM
I am using GCC on FEDORA.
I want to print current date an time. How can do that.
Thanks
-Sanchit
Antoninus Twink
#2
Jun 27 '08, 07:28 PM
Re: How to determine curreent date and time/
On 14 Apr 2008 at 17:14, Sanchit wrote:
I am using GCC on FEDORA.
>
I want to print current date an time. How can do that.
system("date");
Comment
Post
Cancel
Sanchit
#3
Jun 27 '08, 07:28 PM
Re: How to determine curreent date and time/
On Apr 14, 10:21 pm, Antoninus Twink <nos...@nospam. invalidwrote:
On 14 Apr 2008 at 17:14, Sanchit wrote:
>
I am using GCC on FEDORA.
>
I want to print current date an time. How can do that.
>
system("date");
Oh I forgot to mention.. I want a C function for this.
Comment
Post
Cancel
Antoninus Twink
#4
Jun 27 '08, 07:28 PM
Re: How to determine curreent date and time/
On 14 Apr 2008 at 17:39, Sanchit wrote:
On Apr 14, 10:21 pm, Antoninus Twink <nos...@nospam. invalidwrote:
>On 14 Apr 2008 at 17:14, Sanchit wrote:
>>
I am using GCC on FEDORA.
>>
I want to print current date an time. How can do that.
>>
>system("date") ;
>
Oh I forgot to mention.. I want a C function for this.
strftime?
Comment
Post
Cancel
aspinall@oltrelinux.com
#5
Jun 27 '08, 07:28 PM
Re: How to determine curreent date and time/
On 14 Apr, 19:14, Sanchit <sanchitgupt... @gmail.comwrote :
I am using GCC on FEDORA.
>
I want to print current date an time. How can do that.
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(){
time_t now = time(NULL);
struct tm *now_s = localtime(&now) ;
if(now_s == NULL)
return EXIT_FAILURE;
printf("%d-%02d-%02d %02d:%02d:%02d\ n", 1900+now_s->tm_year, ++now_s -
>tm_mon,
now_s->tm_mday, now_s->tm_hour, now_s->tm_min,now_s->tm_sec);
return EXIT_SUCCESS;
}
Bye.
Comment
Post
Cancel
Gordon Burditt
#6
Jun 27 '08, 07:28 PM
Re: How to determine curreent date and time/
>I am using GCC on FEDORA.
>
>I want to print current date an time. How can do that.
In C, time() gets you the current date/time in a time_t format.
Various functions can get that into a printable string format:
ctime()
localtime() followed by strftime()
localtime() followed by asctime()
Comment
Post
Cancel
harsha
#7
Jun 27 '08, 07:28 PM
Re: How to determine curreent date and time/
On Apr 14, 10:39 pm, Sanchit <sanchitgupt... @gmail.comwrote :
On Apr 14, 10:21 pm, Antoninus Twink <nos...@nospam. invalidwrote:
>
On 14 Apr 2008 at 17:14, Sanchit wrote:
>
I am using GCC on FEDORA.
>
I want to print current date an time. How can do that.
>
system("date");
>
Oh I forgot to mention.. I want a C function for this.
Page not found – Kahlert School of Computing
http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_19.html#SEC320
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment