Sponsored Content
Operating Systems Linux Red Hat How to check that a particular value is epoch seconds? Post 302809255 by Don Cragun on Sunday 19th of May 2013 02:16:01 AM
Old 05-19-2013
The standards say that the type time_t is an integral type. They don't specify whether the type is signed or unsigned. On systems with a signed 64-bit time_t, any time from the big bang to the expected collapse of the universe, could be represented as a value specifying seconds before or after the epoch.
These 3 Users Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Epoch

Hi all, i am trying to figure out how i can get a 'Nix box to display epoch time. Is there a command to do this? Do I know what I am talking about or am I an Idiot? Wait dont answer that last question!!!!! Thanx in advance!!!:confused: (2 Replies)
Discussion started by: Bodhi
2 Replies

2. Shell Programming and Scripting

check the file every 15 seconds

Hi All, I need a script which does, script check a file every 15 second, if file not exist, it will create a log file. how can I do it ? thanks Alice (4 Replies)
Discussion started by: alisevA3
4 Replies

3. Shell Programming and Scripting

Epoch time

Guys, i have a question... I have 2 sets of data say "a" and "a+1" which has values in epoch time.. Question is... if i were to get the time difference where diff = "a+1" - "a" can i convert it back to real time duration after the subtraction... OR i need to convert em first before i do the... (1 Reply)
Discussion started by: 12yearold
1 Replies

4. HP-UX

getting the "seconds since epoch" in HP-UX kernel

Hi! I'm writing a kernel module on HP-UX 11.23, and I can't find how to get the “number of seconds since epoch” (midnight of Jan 1st 1970). Actually I'm trying to find an equivalent to the user-space “time()” function... I found that in Linux, one can access “xtime.tv_sec” in the... (1 Reply)
Discussion started by: nati
1 Replies

5. Shell Programming and Scripting

shell script that will automatically check if specifed user is log in or not, in 30 seconds

guys I need emergency help with below shell script assignment..am new to shell script Write a Shell script to automatically check that a specified user is logged in to the computer. The program should allow the person running the script to specify the name of the user to be checked, the... (2 Replies)
Discussion started by: gurmad
2 Replies

6. Shell Programming and Scripting

Date conversion from Standard/given format to seconds/epoch

I am trying get time difference of two dates in secs. Initially I want to convert a standard date format to epoch for two dates and then subtract the two epoch dates. Example : date -d "2007-09-01 17:30:40" '+%s' But this gives me below error date: illegal option -- d Usage: date OS: AIX... (6 Replies)
Discussion started by: bpaac
6 Replies

7. Shell Programming and Scripting

Adding Seconds to UNIX/Epoch-Time

Hello All, I have a Perl script I'm writing where I ask the user to enter a "start time" for something. The "$start_time" will be in the format of: # The Time CLI Option Can be in the format of: --start-time="1day" --start-time="2hours" --start-time="45min" ... (1 Reply)
Discussion started by: mrm5102
1 Replies

8. Shell Programming and Scripting

Current triggered time to epoch seconds

I have a requirement to find long running instances for notifying the stake holders based on the triggered time in AIX. I am not sure how to convert the triggered time to epoch seconds. For example : Current triggered time of instance is 13:06:19 -> how to convert this into epoch in the... (5 Replies)
Discussion started by: chandu123
5 Replies

9. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

10. Shell Programming and Scripting

Convert a future date into epoch seconds on HPUX system

Hi All, I have scenario where i have to compare two dates. I thought of converting them to epoch seconds and do a numeric comparison. This works fine on Linux systems. $ date -d '2015/12/31' +%s 1451538000 $ date +%s 1449159121 But we don't have -d option in HPUX. What would be... (5 Replies)
Discussion started by: veeresh_15
5 Replies
TIME2POSIX(3)						   BSD Library Functions Manual 					     TIME2POSIX(3)

NAME
time2posix, posix2time -- convert seconds since the Epoch LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <time.h> time_t time2posix(time_t t); time_t posix2time(time_t t); DESCRIPTION
IEEE Std 1003.1-1988 (``POSIX.1'') legislates that a time_t value of 536457599 shall correspond to "Wed Dec 31 23:59:59 GMT 1986." This effectively implies that POSIX time_t's cannot include leap seconds and, therefore, that the system time must be adjusted as each leap occurs. If the time package is configured with leap-second support enabled, however, no such adjustment is needed and time_t values continue to increase over leap events (as a true `seconds since...' value). This means that these values will differ from those required by POSIX by the net number of leap seconds inserted since the Epoch. Typically this is not a problem as the type time_t is intended to be (mostly) opaque--time_t values should only be obtained-from and passed- to functions such as time(3), localtime(3), mktime(3) and difftime(3). However, IEEE Std 1003.1-1988 (``POSIX.1'') gives an arithmetic expression for directly computing a time_t value from a given date/time, and the same relationship is assumed by some (usually older) appli- cations. Any programs creating/dissecting time_t's using such a relationship will typically not handle intervals over leap seconds cor- rectly. The time2posix() and posix2time() functions are provided to address this time_t mismatch by converting between local time_t values and their POSIX equivalents. This is done by accounting for the number of time-base changes that would have taken place on a POSIX system as leap sec- onds were inserted or deleted. These converted values can then be used in lieu of correcting the older applications, or when communicating with POSIX-compliant systems. The time2posix() function is single-valued. That is, every local time_t corresponds to a single POSIX time_t. The posix2time() function is less well-behaved: for a positive leap second hit the result is not unique, and for a negative leap second hit the corresponding POSIX time_t does not exist so an adjacent value is returned. Both of these are good indicators of the inferiority of the POSIX representation. The following table summarizes the relationship between time_t and its conversion to, and back from, the POSIX representation over the leap second inserted at the end of June, 1993. DATE TIME T X=time2posix(T) posix2time(X) 93/06/30 23:59:59 A+0 B+0 A+0 93/06/30 23:59:60 A+1 B+1 A+1 or A+2 93/07/01 00:00:00 A+2 B+1 A+1 or A+2 93/07/01 00:00:01 A+3 B+2 A+3 A leap second deletion would look like... DATE TIME T X=time2posix(T) posix2time(X) ??/06/30 23:59:58 A+0 B+0 A+0 ??/07/01 00:00:00 A+1 B+2 A+1 ??/07/01 00:00:01 A+2 B+3 A+2 [Note: posix2time(B+1) => A+0 or A+1] If leap-second support is not enabled, local time_t's and POSIX time_t's are equivalent, and both time2posix() and posix2time() degenerate to the identity function. SEE ALSO
difftime(3), localtime(3), mktime(3), time(3) BSD
September 11, 2005 BSD
All times are GMT -4. The time now is 06:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy