Visit The New, Modern Unix Linux Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #276
Difficulty: Easy
OpenSolaris was based on Solaris, which was originally released by Sun in 1999.
True or False?
Linux & Unix Commands - Search Man Pages

time(2) [linux man page]

TIME(2) 						     Linux Programmer's Manual							   TIME(2)

time - get time in seconds SYNOPSIS
#include <time.h> time_t time(time_t *t); DESCRIPTION
time() returns the time as the number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). If t is non-NULL, the return value is also stored in the memory pointed to by t. RETURN VALUE
On success, the value of time in seconds since the Epoch is returned. On error, ((time_t) -1) is returned, and errno is set appropriately. ERRORS
EFAULT t points outside your accessible address space. CONFORMING TO
SVr4, 4.3BSD, C89, C99, POSIX.1-2001. POSIX does not specify any error conditions. NOTES
POSIX.1 defines seconds since the Epoch as a value to be interpreted as the number of seconds between a specified time and the Epoch, according to a formula for conversion from UTC equivalent to conversion on the naive basis that leap seconds are ignored and all years divisible by 4 are leap years. This value is not the same as the actual number of seconds between the time and the Epoch, because of leap seconds and because clocks are not required to be synchronized to a standard reference. The intention is that the interpretation of sec- onds since the Epoch values be consistent; see POSIX.1 Annex B 2.2.2 for further rationale. SEE ALSO
date(1), gettimeofday(2), ctime(3), ftime(3), time(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at Linux 2010-02-25 TIME(2)

Check Out this Related Man Page

DIFFTIME(3)						     Linux Programmer's Manual						       DIFFTIME(3)

difftime - calculate time difference SYNOPSIS
#include <time.h> double difftime(time_t time1, time_t time0); DESCRIPTION
The difftime() function returns the number of seconds elapsed between time time1 and time time0, represented as a double. Each of the times is specified in calendar time, which means its value is a measurement (in seconds) relative to the Epoch, 1970-01-01 00:00:00 +0000 (UTC). CONFORMING TO
SVr4, 4.3BSD, C89, C99. NOTES
On a POSIX system, time_t is an arithmetic type, and one could just define #define difftime(t1,t0) (double)(t1 - t0) when the possible overflow in the subtraction is not a concern. On other systems, the data type time_t might use some other encoding where subtraction doesn't work directly. SEE ALSO
date(1), gettimeofday(2), time(2), ctime(3), gmtime(3), localtime(3) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at GNU
2010-02-25 DIFFTIME(3)

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

seconds to hh:mm:ss

Any sleek way to convert seconds to hh:mm:ss format . I know it can be done by mod and divide . Looking for a one liner if possible . Example 3600 seconds = 01:00:00 3601 seconds = 01:00:01 (2 Replies)
Discussion started by: akrathi
2 Replies

2. UNIX for Dummies Questions & Answers

Number of leap seconds

Is there a function call in std library or unit command that returns the number of current leap seconds? GG (4 Replies)
Discussion started by: NAVTime
4 Replies

3. UNIX for Dummies Questions & Answers

Unix Command to separate this years files and last years?

Hello - I have a folder that contains files from 2003 till 2010. I am trying to figure out a command that would seperate each years file and show me a count? Even if i can find a command that would give me year by year count, thats good enough too. Thanks (8 Replies)
Discussion started by: DallasT
8 Replies

4. What is on Your Mind?

STILL can't buy a Linux PC easily

A few years ago, Dell announced they were selling PCs with Linux (Ubuntu) preinstalled or with no OS installed. It was about time! So a couple years ago I bought the Inspiron 1525n laptop that I'm typing this on with Ubuntu preinstalled. Yea! (Though I immediately wiped Ubuntu and installed... (7 Replies)
Discussion started by: KenJackson
7 Replies

5. AIX


Hi Guys , I see a weird problem with one of the AIX Machine, The time is changing randomly on the server. The seconds part of the time is what is the problem which is jumping on a uneven order and coming back to the original state after some time and again the same.. I have collected the time... (8 Replies)
Discussion started by: kkeng808
8 Replies

6. Fedora

Starting out, Linux Distribution

Hi, i'm currently part of an apprenticeship becoming a IT specialist. Because I'm already an electronic technician (finished apprenticeship) I can do this one in 2 years (normally you need 3). Thing is, in school they started out with basic unix stuff (working with the shell) in the first... (3 Replies)
Discussion started by: Dr. Nick
3 Replies

7. Shell Programming and Scripting

Epoch & Unix Timestamp Conversion Tools

Hi All, Please read the below data carefully. I need an unix command for converting unix timestamp to Epoch timestamp. I need to daily convert this today's unix(UTC) time to epoch time, so i am thinking to make a shellscript for this. Please help me for this by providing... (3 Replies)
Discussion started by: aish11
3 Replies

8. Shell Programming and Scripting

Shell Script for Epoch Time Conversion

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

9. Shell Programming and Scripting

If then logic with TIME

Hi all, Can anyone suggest how to formulate the if/then when TIME equals a certain time, in this case 23:55:00 export TIME=`date +%T` function tnsrec { if $TIME = 23:55:00; then otherfunction else exit fi } Thanks in advance. jd (6 Replies)
Discussion started by: jonnyd
6 Replies

10. Shell Programming and Scripting

What does this mean?

Hello all, I am a newbie in shell scripting. I want to know what does the below text means? 6.355u 1.679s 0:12.68 63.2% 0+0k 0+0io 0pf+0w I am getting this line (on terminal) after every successful execution of my script. Thanks in advance . . :) -MD (15 Replies)
Discussion started by: manands07
15 Replies

11. Programming

How to contribute Linux in Development?

Hello, I am a Linux/Unix System Administrator as a profession from last 8 years and now want to jump into Linux programming to contribute something to this in which i spent these many years for its integration/Administration/Configuration/Servers Setups. Please let me know i can start working... (5 Replies)
Discussion started by: sunnysthakur
5 Replies

12. Shell Programming and Scripting

Change the seconds value in date column

Hello, I have a file with below contents and need to set seconds value to 00 (as you can see few time stamps are with 01 seconds) 18:16:00 8192 7301 89 11 18:21:00 8192 7305 89 11 18:26:00 8192 7306 89 11 18:31:00 8192 7306 ... (6 Replies)
Discussion started by: reddyr
6 Replies

13. UNIX for Dummies Questions & Answers

Convert Epoch to timestamp in a file

Hi Team, Could you please let me know ,how to convert Epoch column to timestamp in a flat file. "57894"|"1454247163111"|"""HH""" "57897"|"1454247163111"|"""HH""" "7906"|"1454247163111"|"""ss""" I want second field as timestamp. This thread has been moved from a non-technical forum to... (6 Replies)
Discussion started by: shabeena
6 Replies

14. Shell Programming and Scripting

Duration Calculation

I have 2 variables startTime='122717 23:20' endTime='122817 0:40' how can i get the elapsed duration as like "1 hour 20 minutes" ? (8 Replies)
Discussion started by: vikram3.r
8 Replies

15. What is on Your Mind?

I'll probably never be the best in the field...

I don't know how to start this but here goes. I've been "using" Linux for over 10 years, possibly more and I still feel like I'm nowhere where I should be. I'll be fair most of my time was spent either figuring out how to run games on *nix at the time but as I got older and "wiser" I... (8 Replies)
Discussion started by: samthewildone
8 Replies

Featured Tech Videos