Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to display a specific date in Unix, using the date command, I can't figure out how to display a date other than today's date.

For example, if I was trying to display July 4, 2011 I use

$ date +"%B %d, %Y"

But I keep getting today's date in that format. How can I change it so that it displays the date I want?

share|improve this question

If you're running Linux:

date +"%B %d, %Y" -d 2011-07-04

From man date:

   -d, --date=STRING
          display time described by STRING, not 'now'
share|improve this answer
The answer largely depends on the particular flavour of UNIX the user32270 is using. For example, the suggested variant will not work on HP-UX or older SunOS, in fact, there's no way to display an arbitrary date by date there. – Leonid Feb 13 '13 at 5:52
@Leonid - Either way, this information will be in man if it is possible in their environment. – Chris Down Feb 13 '13 at 6:28

Generally, date is not the tool for that (though some implementations, like GNU date can do it as a non-standard extension).

If you want to do date manipulation portably, the best you can do is probably to use perl (which is installed on virtually every non-embedded Unix) and its POSIX module for the strftime and mktime functions. There is a plethora of other friendlier date manipulation modules for perl but they would generally not be installed by default, at least not with older versions of perl.

perl -MPOSIX -le 'print strftime "%B %d, %Y", @ARGV' 0 0 0 4 7 "$((2011 - 1900))"
share|improve this answer

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.