[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
date
Here are a few examples. Also see the documentation for the `-d' option in the previous section.
date --date='2 days ago' |
date --date='3 months 1 day' |
date --date='25 Dec' +%j |
date '+%B %d' |
But this may not be what you want because for the first nine days of the month, the `%d' expands to a zero-padded two-digit field, for example `date -d 1may '+%B %d'' will print `May 01'.
-
modifier to suppress
the padding altogether.
date -d 1may '+%B %-d |
date
when setting the system clock:
date +%m%d%H%M%Y.%S |
date --set='+2 minutes' |
Mon, 25 Mar 1996 23:34:17 -0600 |
date --date='1970-01-01 00:02:00 +0000' +%s 120 |
If you do not specify time zone information in the date string,
date
uses your computer's idea of the time zone when
interpreting the string. For example, if your computer's time zone is
that of Cambridge, Massachusetts, which was then 5 hours (i.e., 18,000
seconds) behind UTC:
# local time zone used date --date='1970-01-01 00:02:00' +%s 18120 |
date --date='2000-01-01 UTC' +%s 946684800 |
To convert such an unwieldy number of seconds back to a more readable form, use a command like this:
# local time zone used date -d '1970-01-01 UTC 946684800 seconds' +"%Y-%m-%d %T %z" 1999-12-31 19:00:00 -0500 |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |