UNIX Quick Tip: See the current UNIX Timestamp and other date formats on the command line

The UNIX date command can show the current (or a future) date in several different formats. The command’s default output presents a full date string:

date
 
Sat Mar  7 07:25:51 SAST 2009

… but this output can be modified by specifying certain arguments.

To see the output in a different format:

date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S"
 
DATE: 2009-03-07
TIME: 07:27:43

To see the last Friday of the month:

date -v1d -v+1m -v-1d -v-fri
 
Fri Mar 27 07:29:28 SAST 2009

To display the current UNIX Timestamp:

date +%s
 
1236403850

The date command has several other arguments which can be found by reviewing its man page:

man date

 

Related posts:

  1. Mac OS X Quick Tip: Using Spotlight to search from the command line
  2. Reusing commands with different arguments on a Bash command line
  3. Checking directory sizes on a Bash command line
  4. UNIX Quick Tip – Repeat the last entered command with ‘!!’ (Bang bang)
  5. Testing SMTP servers from a UNIX command line
Twitter Digg Delicious Stumbleupon Technorati Facebook Email

No comments yet... Be the first to leave a reply!

Afrigator