471,092 Members | 1,058 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

difference in time between sun and linux

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..

Jul 7 '06 #1
3 1601

rr********@gmail.com wrote:
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.

Jul 7 '06 #2
rr********@gmail.com writes:
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.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 7 '06 #3

Bill Pursell wrote:
rr********@gmail.com wrote:
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.
yes.. ur right.
the timezone was different on the two machines.
the env varialble TZ was incorrectyly set.
sorry once again.
thanks.

Jul 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Michele A. | last post: by
6 posts views Thread by Bjørn T Johansen | last post: by
4 posts views Thread by Harro de Jong | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.