Operating System - HP-UX
1847837 Members
4648 Online
104021 Solutions
New Discussion

Re: Problem with C++ programming in rp7410

 
kevin_92
Occasional Contributor

Problem with C++ programming in rp7410

Hi,

I have a problem with C++ programming,my host is rp7410, when I used time(now) function to get system time,i found that the time is 13 hours slower than current time.but i use date command, the output is right.Why?

3 REPLIES 3
Steven E. Protter
Exalted Contributor

Re: Problem with C++ programming in rp7410

What is the TZ on your system?

echo $TZ

Could you paste in the code you are using and the two outputs?

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
kevin_92
Occasional Contributor

Re: Problem with C++ programming in rp7410

$ echo $TZ
$ ETA-8

My application is running as following:#su - aps -c "./application &". Recently i check the application log, and find the log time is 11 hours less.
A. Clay Stephenson
Acclaimed Contributor

Re: Problem with C++ programming in rp7410

First of all, the time() system call does not return a human time in any sense. It simply returns (or loads a value pointed to) with epoch seconds -- the number of seconds since Jan 1, 1970 00:00:00 UTC. You can only get this epoch time converted into something more meaningful by using a time-formatting function like localtime(),gmtime(), or stdftime(). If these functions are returning strange values then I suggest that you do a getenv("TZ") call within your program and display that value. All of these epoch seconds to formatted time functions take TZ into account.
If it ain't broke, I can fix that.