473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 1720

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Michele A. | last post by:
The following code in NT results in no border around the text box. On XP, the border appears. I don't want a border, but I need the value to post so I can't use a label. Does anyone have a...
6
by: Bjørn T Johansen | last post by:
I need to compute the difference of Time fields, in the format HHMM. Is it possible to do the math in the Select? Regards, BTJ --...
28
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and...
4
by: Harro de Jong | last post by:
(absolute beginner here, sorry if this seems basic) Section 7.10 of 'How to Think Like a Computer Scientist' contains this discussion of string.find and other string functions: (quote) We can...
9
by: Brian | last post by:
I have been a Mac and linux guy since 1998 and except for a handful of times, have not touched a MS box since then. This changes a few days ago when I needed to get a MS box for another project. ...
9
by: de | last post by:
between c and c++ I have understood is preferibile c++, but always? and regarding C# what changes? Moreover which are the main differences between the rad Turbo C++, Borland Studio6 C++, Visual...
19
by: xianwei | last post by:
#include <stdio.h> #include <stdlib.h> #include <time.h> int main ( int argc, char *argv ) { long i = 10000000L; clock_t start, end; double duration;
7
by: coolsti | last post by:
I have just noticed a very large difference in memory usage for the PHP applications that I have developed for my company between my developmental machine and the "production" machine: Development...
4
by: tvnaidu | last post by:
Porting small application from windows to embedded system, not decided what to use whether RTOS or Embedded Linux, is there big difference between RTOS and embedded Linux?. also I need to reduce...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.