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 ?
The Unix time is given as seconds since the epoch: the number of seconds (not counting leap seconds) that have passed since 00:00:00 Coordinated Universal Time (UTC), or Thursday, January 1st, 1970,
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
1402566271
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
558450000
And to convert that back to a "normal" date:
$ date -d "@558450000"
Sat Sep 12 15:00:00 CEST 1987
date -d 3pm will still work and is the same as date -d "3pm today"
3:00PM is meaningless in terms of Unix time and only 3:00 PM today makes sense.
$TZ.
1am can be ambiguous as in most countries (the ones implementing DST) there is one day of the year where that time occurs twice.
date -d @1402565420orTZ=your-timezone-abbreviation date -d @1402565420.