Skip to content

Counting the days on Linux

Have you ever wondered how many days it’s been since you started your diet, begun your daily jogs, or were first working with Linux? If you can remember the start date, a simple Linux script can count the days for you. All you need is the date command and a calculation that turns your dates into seconds, subtracts the start date from the end date and then divides the result by the appropriate number to turn the seconds into the corresponding number of days.

Why seconds?

The reason for the conversion to days is that the date command can display a date as the number of seconds since the start of the Linux epoch—10=970-01-01. This is the only option date provides for looking at the time difference between two calendar dates.

To read this article in full, please click here

Source:: Network World – Linux