* RE: <time.h>: gmtime keeps giving the same time ....
@ 2003-05-09 2:56 Ranga Reddy M - CTD ,Chennai.
2003-05-09 19:46 ` <time.h>: solved thank you J.
0 siblings, 1 reply; 2+ messages in thread
From: Ranga Reddy M - CTD ,Chennai. @ 2003-05-09 2:56 UTC (permalink / raw)
To: J., linux-c-programming
Hi,
Here you are comparing the gmtime() output to The "date" command.
see the man pages of gmtime().This will give you the time in UTC format.
use localtime(). Gives same as your "date" output.
I have modified your code .Know it gives the
The code below.
#include <stdio.h>
#include <time.h>
int main(void) {
struct tm *tm_ptr;
time_t the_time;
(void)time(&the_time);
tm_ptr = localtime(&the_time);
printf("tm_ptr->tm_hour = %d\n", tm_ptr->tm_hour);
return 0;
}
Cheers
--------
Ranga Reddy M
-----Original Message-----
From: J. [mailto:mailing-lists@xs4all.nl]
Sent: Friday, May 09, 2003 1:17 AM
To: linux-c-programming@vger.kernel.org
Subject: <time.h>: gmtime keeps giving the same time ....
Hello,
Output from the date `command` in my terminal:
Thu May 8 21:42:28 CEST 2003
Output from my `problem'_program.c
19
#include <stdio.h>
#include <time.h>
int main(void) {
struct tm *tm_ptr;
time_t the_time;
(void)time(&the_time);
tm_ptr = gmtime(&the_time);
printf("tm_ptr->tm_hour = %d\n", tm_ptr->tm_hour);
return 0;
}
No matter what I do, this C - code keeps giving me as output 19.
Is my system messed up or my head ?
Any thoughts are more than welcome
Thnkx....
J.
-
To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: <time.h>: solved thank you ....
2003-05-09 2:56 <time.h>: gmtime keeps giving the same time Ranga Reddy M - CTD ,Chennai.
@ 2003-05-09 19:46 ` J.
0 siblings, 0 replies; 2+ messages in thread
From: J. @ 2003-05-09 19:46 UTC (permalink / raw)
To: linux-c-programming
On Fri, 9 May 2003, Ranga Reddy M - CTD ,Chennai. wrote:
>
> Hi,
>
> Here you are comparing the gmtime() output to The "date" command.
>
> see the man pages of gmtime().This will give you the time in UTC format.
> use localtime(). Gives same as your "date" output.
>
> I have modified your code .Know it gives the
> The code below.
>
> #include <stdio.h>
> #include <time.h>
>
> int main(void) {
> struct tm *tm_ptr;
> time_t the_time;
>
> (void)time(&the_time);
> tm_ptr = localtime(&the_time);
>
> printf("tm_ptr->tm_hour = %d\n", tm_ptr->tm_hour);
>
> return 0;
> }
>
> Cheers
> --------
> Ranga Reddy M
Thank you for the complete reply !
I understand what I did wrong, and how to do it better next time.
Merci....
J.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-05-09 19:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-09 2:56 <time.h>: gmtime keeps giving the same time Ranga Reddy M - CTD ,Chennai.
2003-05-09 19:46 ` <time.h>: solved thank you J.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).