difference in time between sun and linux

R

rrs.matrix

i have a problem
i have a file which contains the time and is generated on sun machine.
i have to decode the time on linux machine.
the problem is that the sun machine shows different time and the linux
machine shows
different time.
below is the code i have used to test the time.
On SUN machine
#include<stdio.h>
#include<time.h>
int main()
{
time_t tme=1106661607;
printf("\nTime:%s",ctime(&tme));
return 0;
}
output:Time:Tue Jan 25 09:00:07 2005

On Linux
#include<time.h>
int main()
{
time_t tme=1106661607;
printf("\nTime:%s",ctime(&tme));
return 0;
}
output:Time:Tue Jan 25 06:00:07 2005

how can i solve this problem..
 
B

Bill Pursell

i have a problem
i have a file which contains the time and is generated on sun machine.
i have to decode the time on linux machine.
the problem is that the sun machine shows different time and the linux
machine shows
different time.
below is the code i have used to test the time.
On SUN machine
#include<stdio.h>
#include<time.h>
int main()
{
time_t tme=1106661607;
printf("\nTime:%s",ctime(&tme));
return 0;
}
output:Time:Tue Jan 25 09:00:07 2005

On Linux
#include<time.h>
int main()
{
time_t tme=1106661607;
printf("\nTime:%s",ctime(&tme));
return 0;
}
output:Time:Tue Jan 25 06:00:07 2005

how can i solve this problem..

The problem has very little to do with C. Most likely it is an
environment issue (timezone, daylight savings, etc). Try
comp.unix.programmer.
 
K

Keith Thompson

i have a problem
i have a file which contains the time and is generated on sun machine.
i have to decode the time on linux machine.
the problem is that the sun machine shows different time and the linux
machine shows
different time.
below is the code i have used to test the time.
On SUN machine
#include<stdio.h>
#include<time.h>
int main()
{
time_t tme=1106661607;
printf("\nTime:%s",ctime(&tme));
return 0;
}
output:Time:Tue Jan 25 09:00:07 2005

On Linux
#include<time.h>
int main()
{
time_t tme=1106661607;
printf("\nTime:%s",ctime(&tme));
return 0;
}
output:Time:Tue Jan 25 06:00:07 2005

how can i solve this problem..

ctime() gives you local time. It looks like the Sun machine is on PDT
(U.S. Pacific Daylight Time) and the Linux machine is on EDT
(U.S. Eastern Daylight Time). (The reason I know this is strictly
off-topic; the standard doesn't guarantee any particular
representation for time_t.)

ctime(t) is equivalent to asctime(localtime(timer)). You can use
gmtime() rather than localtime() to get UTC rather than local time.
 
R

rrs.matrix

Bill said:
The problem has very little to do with C. Most likely it is an
environment issue (timezone, daylight savings, etc). Try
comp.unix.programmer.

yes.. ur right.
the timezone was different on the two machines.
the env varialble TZ was incorrectyly set.
sorry once again.
thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top