RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Unix / Linux epoch time conversions examples

Many UNIX application are using an EPOCH time to determine a date, on most Linux systems an EPOCH time started on 1.1.1970 and will end on 18.1.2038 as defined by a time_t UNIX C library. Epoch time digit contains a number of seconds since the start of epoch ( 1.1.1970 and 10 hours ).


To get a better understanding consider an example where epoch number is "1". Now convert this epoch time to a real time/ When using bash we can execute a following command:

~$ date --date "Jan 1, 1970 00:00:00 +0000 + 1 seconds"
Thu Jan  1 10:00:01 EST 1970

To get a current epoch time we simply use date command as follows:

~$ date +%s
1284763671

As already mentioned above, to convert a epoch time digit to real time we can use for example by
BASH:

~$ date --date "Jan 1, 1970 00:00:00 +0000 + 1284763671 seconds"
Sat Sep 18 08:47:51 EST 2010

or

date -d@1284763671
Sat Sep 18 08:47:51 EST 2010

PERL:

~$ perl -e 'print scalar(localtime(1284763671)), "\n"'
Sat Sep 18 08:47:51 2010

NOTE:

To convert to Coordinated Universal Time using bash type:

~$ date -ud@1284763671
Fri Sep 17 22:47:51 UTC 2010

Share this linux post:

Submit Unix / Linux epoch time conversions examples in Delicious Submit Unix / Linux epoch time conversions examples in Digg Submit Unix / Linux epoch time conversions examples in FaceBook Submit Unix / Linux epoch time conversions examples in Google Bookmarks Submit Unix / Linux epoch time conversions examples in Stumbleupon Submit Unix / Linux epoch time conversions examples in Technorati Submit Unix / Linux epoch time conversions examples in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download