04-22-2002
Look at the the gettimeofday() system call. It can deal with timezones. Alternately at the command line you could just do something like:
TZ=GMT0 date
Which would return the Dreenwhich Mean Time (aka UTC). You could substitute any timezone specification:
TZ=PST8PDT date
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hello gurus,
i want a perl/shell script which once invoked should convert a set of EPOCH timestamps to local time ( IST..i want) .
how does it work ,i have an idea on that..but writing a perl/shell script for it is not possible for me...so i need help for the same.
my exact requirement is... (2 Replies)
Discussion started by: abhijeetkul
2 Replies
2. Programming
Hi frnds,
I have written a code to get current time
struct tm *locTime;
time_t currentTime;
time( ¤tTime );
locTime = localtime(¤tTime );
Suppose now i get output time as 31-DEC-2007 00:00:00
What i want now is i want two strings where in one string i want to subtract... (1 Reply)
Discussion started by: electroon
1 Replies
3. Windows & DOS: Issues & Discussions
help me to convert unix time format into windows time format using java
i have linux time ex. 1075329297.572 (2 Replies)
Discussion started by: sari
2 Replies
4. Shell Programming and Scripting
My local server is in UTC time whereas my remote server in in CST time.
I get a sequential file from CST time server and the records in will contain the first line as a filename and the second line as date time like mentioned below.
/abc/cde/f1.txt
2009-04-28 23:10:05 CST
Now i need to... (3 Replies)
Discussion started by: HemaV
3 Replies
5. Shell Programming and Scripting
hi,
i've got an input file that contains
12345678 AAA
12345679 BBB
12345680 CCC
where 1st column is epoch time while the second column are some string.
I'm using nawk to do regular expression on the 2nd column and i need to convert the epoch time to human readable time e.g. 'yyyymmdd... (5 Replies)
Discussion started by: bing
5 Replies
6. Shell Programming and Scripting
Hello All,
I have a requirement to convert a 12 hour format to 24 hour time format and the sample input /out put is below
Input Time format : Nov 2 2011 12:16AM
Out Put Format : Nov 2 2011 0:16
Input : Nov 2 2011 4:16PM
Out Put: Nov 2 2011 16:16
I have done this using a... (6 Replies)
Discussion started by: jambesh
6 Replies
7. Shell Programming and Scripting
Hi there
I came across this script online to convert Epoch time to proper date format, but I am receiving the following error
Also, I have HISTTIMEFORMAT set in user's .profile so that their history output shows time stamps. Additionally I have changed their .history location to a dedicated... (9 Replies)
Discussion started by: hedkandi
9 Replies
8. Programming
Hi. I have timestamps that I am trying to convert to epoch time. An example:
I am trying to convert this to an epoch timestamp but have one little glitch. I have this:
import time
date_time = ''
pattern = ''
epoch = int(time.mktime(time.strptime(date_time, pattern)))
print epoch... (1 Reply)
Discussion started by: treesloth
1 Replies
9. Shell Programming and Scripting
I am trying to convert local time to time in Ireland. Instead it is going the opposite direction (taking the local time as it if were in Ireland and displaying that the time would be here).
$ echo "$TZ"; date; date --date='TZ="Europe/Dublin" '"$(date)"
America/Phoenix
Mon, Apr 13, 2015... (7 Replies)
Discussion started by: Michael Stora
7 Replies
10. Shell Programming and Scripting
How can I convert the following date format:
New Log Date = 2016-12-30 23:50:33 GMT
from GMT time to local time?
Thanks (13 Replies)
Discussion started by: mrn6430
13 Replies
LEARN ABOUT NETBSD
gettimeofday
GETTIMEOFDAY(2) BSD System Calls Manual GETTIMEOFDAY(2)
NAME
gettimeofday, settimeofday -- get/set date and time
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <sys/time.h>
int
gettimeofday(struct timeval * restrict tp, void * restrict tzp);
int
settimeofday(const struct timeval * restrict tp, const void * restrict tzp);
DESCRIPTION
Note: time zone information is no longer provided by this interface. See localtime(3) for information on how to retrieve it.
The system's notion of the current UTC time is obtained with the gettimeofday() call, and set with the settimeofday() call. The time is
expressed in seconds and microseconds since midnight (0 hour), January 1, 1970. The resolution of the system clock is hardware dependent,
and the time may be updated continuously or in ``ticks''.
If tp is NULL, the time will not be returned or set. Despite being declared void *, the objects pointed to by tzp shall be of type struct
timezone.
The structures pointed to by tp and tzp are defined in <sys/time.h>. The first one is described in timeval(3) and the latter legacy struc-
ture is defined as:
struct timezone {
int tz_minuteswest; /* of Greenwich */
int tz_dsttime; /* type of dst correction to apply */
};
The timezone structure is provided only for source compatibility. It is ignored by settimeofday(), and gettimeofday() will always return
zeroes.
If the calling user is not the super-user, then the settimeofday() function in the standard C library will try to use the clockctl(4) device
if present, thus making possible for non privileged users to set the system time. If clockctl(4) is not present or not accessible, then
settimeofday() reverts to the settimeofday() system call, which is restricted to the super user.
RETURN VALUES
A return value 0 indicates that the call succeeded. A return value -1 indicates an error occurred, and in this case an error code is stored
into the global variable errno.
ERRORS
The following error codes may be set in errno:
[EFAULT] An argument address referenced invalid memory.
[EPERM] A user other than the super user attempted to set the time, or the specified time was less than the current time, which
was not permitted at the current security level.
SEE ALSO
date(1), adjtime(2), ctime(3), localtime(3), clockctl(4), timed(8)
HISTORY
The gettimeofday() function call appeared in 4.2BSD. The tzp argument was deprecated in 4.4BSD (and many other systems).
BSD
May 18, 2010 BSD