Unix, Linux and epoch time

Date:



Working on Linux doesn’t often require that we contemplate epoch time, but the concept plays an important role in a “behind the scenes” kind of way. Epoch time is based on the number of seconds since 00:00:00 on January 1, 1970, and is used to record dates/times on Linux systems in an abbreviated format. For example, Jan 2, 1970, would have been saved as 86400 (that many seconds later than Jan 1, 1970). That’s 60 x 60 x 24 – the number of seconds in a single day. Jan 3, 1970, started at 172800 (2 x 86400) seconds after the start of Jan 1, 1970, and Jan 4, 1970, started another 86400 seconds later, and so on.

There are three dates and times associated with Linux files – the last access time (atime), the date and time when the content of the file was last modified (mtime), and the last time that the file’s metadata (e.g., file permissions) were changed (ctime). All of these dates and times are stored in the inodes that are associated with the particular files.

To view these dates and times, you can use the stat command which, in the example below, also shows the file’s “birth” time – which many versions of Linux do not report – along with the file size, owner, permissions, inode number, etc. This information is also stored in the file’s inode.

$ stat xyz
  File: xyz
  Size: 1297            Blocks: 8          IO Block: 4096   regular file
Device: 0,42    Inode: 22965       Links: 1
Access: (0660/-rw-rw----)  Uid: ( 1001/     shs)   Gid: ( 1001/     shs)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2024-02-17 10:53:45.295165033 -0500
Modify: 2024-02-17 10:59:03.335266910 -0500
Change: 2024-02-17 10:59:40.891623555 -0500
 Birth: 2024-02-17 10:03:16.379458282 -0500

While the list of the dates and times above may all look somewhat normal, they display a long string of nanoseconds (e.g., 335266910) and an indication of the time zone (-0500) associated with the date. The time zone in this example (-0500) means GMT-5 (Eastern US).

The date command can do some handy conversions for you if you’d like to display the current time in the epoch (seconds since the start of Jan 1, 1970) format. The examples below show the commands to use.

To display the current epoch time (i.e., show the date as the number of seconds since Jan 1, 1970), use the command shown below:



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Share post:

Advertise With Us

For a sponsored / Paid / Guest Post. advertisers that target the software, games, telecom and IT industry. contact us at dagoldinfo@gmail.com

Popular

More like this
Related

Military Smart Watch for Men 1.96 Inches Outdoor Sports Smartwatch with Answer/Make Call,Fitness watch,Blood Oxygen,Heart Rate and Sleep Monitor Compatible with iPhone and Android...


【Durable Military-grade Construction】The Smart Watch is made from a special aluminum alloy material, our Military Smart Watch for Men has undergone rigorous military-grade testing, including extreme temperature, low pressure, and dust resistance. This watch can withstand harsh environmental conditions, making it the perfect companion for outdoor adventures.
【Convenient Call and Message Functions】Stay connected on the go with our Military Smart Watch for Men. With the ability to make and answer calls, you can stay connected wherever you go. The call and text capabilities allow you to stay in touch with friends, family, and colleagues at all times. It also seamlessly integrates with popular social media platforms such as Facebook, WhatsApp, and Twitter. Receive notifications directly on your wrist.
【Comprehensive Health Monitoring】Monitor your heart rate, blood oxygen levels, and sleep patterns to achieve a holistic understanding of your overall health and well-being. Sedentary reminder, drinking water reminder functions and stress testing prompt you to remain active and stay hydrated throughout the day, maintaining your peak performance levels.
【Multi-Sport Modes and Fitness Tracking】With its step, distance, and calorie burned tracking capabilities, this smart watch provides real-time data to help you monitor your daily exercise routine. Whether you're walking, running, playing basketball, football, cycling, rope skipping, or even mountain climbing, this smart watch has multiple sports modes to cater to your specific workout needs.
【Versatile Functions】The smart watch equipped many other strong functions, such as Ai voice ,weather forecasts, alarm clocks, remote camera , music control, stop watch, find phone, customize your dial, raise hand to brighten the screen,calculator, not-disturb mode and so on. More joy of the watch is waiting for you to explore.
【Wide Compatibility and Large Battery capacity】Smart watch is compatible with most iOS 8.0 and Android 4.4 and later smartphones. Our Military Smart Watch equipped with a large capacity battery, providing long-lasting power for extended outdoor adventures or busy days. Spend more time using your smartwatch and less time worrying about charging.