- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to set timezone variable in gettimeofday
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 05:41 AM
10-02-2002 05:41 AM
how to set timezone variable in gettimeofday
Who can help me ?
Thanx
Laurent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 05:47 AM
10-02-2002 05:47 AM
Re: how to set timezone variable in gettimeofday
Edit /etc/TIMEZONE file as per your location
TZ=SST-8
export TZ
then in /etc/profile
# Set the TIMEZONE
if [ -r /etc/TIMEZONE ]
then
. /etc/TIMEZONE
else
TZ=MST7MDT # change this for local time.
export TZ
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 05:53 AM
10-02-2002 05:53 AM
Re: how to set timezone variable in gettimeofday
"Newer" libc revisions support the timezone default file /etc/default/tz. They use this timezone, whenever no TZ variable is set.
Check if your libc is capable:
# strings /usr/lib/libc.* |grep default/tz
/etc/default/tz
/etc/default/tz
/etc/default/tz
Then this should work:
# unset TZ
# date
Wed Oct 2 09:58:30 EDT 2002
# echo MET-1METDST > /etc/default/tz
# date
Wed Oct 2 15:58:48 METDST 2002
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 05:55 AM
10-02-2002 05:55 AM
Re: how to set timezone variable in gettimeofday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 05:56 AM
10-02-2002 05:56 AM
Re: how to set timezone variable in gettimeofday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 05:59 AM
10-02-2002 05:59 AM
Re: how to set timezone variable in gettimeofday
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 06:02 AM
10-02-2002 06:02 AM
Re: how to set timezone variable in gettimeofday
I have a TZ variable on my system set to MET-1METDST
that's ok and I get correct time when I use the command date.
The problem I have is that when I use gettimeofday with or without timezone variable, the hour I get is wrong (it seems that it does not take into account the summer time (GMT -2) in France . So the time is one hour too small (GMT-1)...
Is that clearer?
Thanx again to those who take time to answer!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 06:14 AM
10-02-2002 06:14 AM
Re: how to set timezone variable in gettimeofday
One moment... you are really using gettimeofday(2)? This is a system call... and the man page says:
The gettimeofday() function obtains the current time, expressed as
seconds and microseconds since 00:00 Coordinated Universal Time (UTC),
January 1, 1970, and stores it in the timeval structure pointed to by
tp. The resolution of the system clock is unspecified.
So this is of course NOT depending in TZ.
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2002 09:06 AM
10-02-2002 09:06 AM
Re: how to set timezone variable in gettimeofday
SYNOPSIS
#include
int gettimeofday(struct timeval *tp,
struct timezone *tzp);
DESCRIPTION
The structures pointed to by tp and tzp are defined in
struct timeval {
unsigned long tv_sec; /* seconds since Jan. 1, 1970 */
long tv_usec; /* and microseconds */
};
struct timezone {
int tz_minuteswest; /* of UTC */
int tz_dsttime; /* type of DST correction to apply */
};
The timezone structure indicates the local time zone (measured in
minutes of time westward from UTC), and a flag that, if nonzero,
indicates that Daylight Savings Time applies locally during the
appropriate part of the year. Programs should use this time zone
information only in the absence of the TZ environment variable.
Security Restrictions
Only a user with appropriate privileges can set the time of day.
RETURN VALUE
gettimeofday() return the following values:
0 Successful completion.
-1 Failure. errno is set to indicate the error.
ERRORS
gettimeofday() fails, errno is set to the following value.
[EFAULT] An argument address referenced invalid memory.
The reliable detection of this error is
implementation dependent.
and I use this call to store the current timestamp in some file.
When I read the file and intrepret the timestamp, with mktime and localtime_r
I have a delta of 1 hour