Why does Linux keep time from Jan 01 1970

01 Jan 1970 is epoch or Unix time or posix time start date, its similar to Before Christ(BC) and After Death(AD). This is the time elapsed from Midnight Jan 01 1970 in UTC time when Unix I is first invented.  The Unix time is zero at this time and it start ticking from that time to till date in seconds. So our Linux machines too kept this as standard time for them. Present Unix time in my system is 1307342993.Which are no of seconds from 12AM 01 Jan 1970 UTC(Coordinated Universal Time).

Where is this Unix time used?

In many places in Linux such as..

  1. In Shadow file for checking user expiry times, password reset times etc for user management in Linux/Unix.
  2. In Log files


How to get present Unix time?

	date +%s

How to get Unix time for a date?. For example I want Unix time for 2009-01-01


How to get today's date?


I know Unix time, how can I convert this Unix time to the equivalent date?

	date -d @epochtime
	date -d @1307343577


	Mon Jun  6 12:29:37 IST 2011

In my shadow file in the 3rd field it's giving last password change date as 14969, how can i change it to actual date of password change for that user?

	date -d @$((86400*14969)) +"%d-%m-%Y %T"
	26-12-2010 05:30:00

Let me explain this command

we are converting no of days(14969) to seconds(day =60*60*24=86400), then w are asking date command to give output of date in d-m-y s format.

Show your love by sharing this..!
Share on VKShare on StumbleUponShare on YummlyPrint this pageFlattr the authorShare on TumblrEmail this to someoneBuffer this pageShare on Google+Share on LinkedInShare on FacebookTweet about this on TwitterPin on PinterestShare on RedditDigg this
The following two tabs change content below.
My name is Surendra Kumar Anne. I hail from Vijayawada which is capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. I work with ICE systems, Sydney as Sr. Consultant. You can contact me at surendra (@) linuxnix dot com.
  • Pingback: Linux Shadow file explained in detail | The Linux Juggernaut()

  • tmt

    AD comes from Anno Domini latin for “The Year of Our Lord”.

    • http://www.linuxnix.com Surendra Anne

      Thanks TMT for your comment.

  • Paula clark

    If you look at the calculation I think (know) that 265 should read 365

    • http://www.linuxnix.com Surendra Anne

      My mistake. Updated the post.