Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How does the Unix time format work? For example, the Unix time for 3:00 PM is:

Normal time format <----3:00PM = 1402565420----> Unix Time

How can I make it understand the time as 3:00 PM ?

share|improve this question
1402565420 may be 3pm on a specific date in your specific timezone. Tomorrow 3pm in your timezone will be 1402651820. See en.wikipedia.org/wiki/Unix_time for details: "Unix time (aka POSIX time or Epoch time), is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970." –  yeti Jun 12 '14 at 9:55
To convert these tomestamps, try date -d @1402565420 or TZ=your-timezone-abbreviation date -d @1402565420. –  yeti Jun 12 '14 at 10:00
Wow Cool the command Works Perfect –  Infected Root Jun 12 '14 at 10:34

1 Answer 1

up vote 10 down vote accepted

The Unix time is given as seconds since the epoch, the number of seconds that has passed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds.

The GNU date command has some very nice features that allow you to translate between different time formats. These are explained very nicely in man date so I will only give you some examples here:

### "Normal" format
$ date
Thu Jun 12 11:44:23 CEST 2014
### Unix time
$ date +%s

To convert, you can give date a specific date using the -d flag. However, to get a Unix date, this needs to be a full date. You can't convert 3:00PM to Unix time since Unix time refers to an entire date (year,month,day,time). So, for example, to get the Unix date for the 12th of September 1987, you would do:

$ date -d "3 PM 12 September 1987" +%s

And to convert that back to a "normal" date:

$ date -d "@558450000" 
Sat Sep 12 15:00:00 CEST 1987
share|improve this answer
date -d 3pm will still work and is the same as date -d "3pm today" –  Stéphane Chazelas Jun 12 '14 at 10:04
@StéphaneChazelas yes, but as you said, it will give today's time. The point I was making to the OP is that 3:00PM is meaningless in terms of Unix time and only 3:00 PM today makes sense. –  terdon Jun 12 '14 at 10:07
I suggest that it should be noticed that Unix time is absolute, while my "3pm today" can be very different from your "3pm today"... depending on $TZ. –  Rmano Jun 12 '14 at 15:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.