By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

difference in time between sun and linux

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a

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

P: n/a
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

P: n/a

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.