date unix command

date

date reports the date and time to stdout.

Timezone

To pick the timezone, you can set the TZ variable before you print the date. e.g.


$ TZ=Australia/Sydney date
Thu, Jun 28, 2012  7:53:33 AM

$ TZ=America/New_York date
Wed, Jun 27, 2012  5:53:34 PM

If you are automating scripts then you can use UTC timezone to avoid issues when migrating your script between environments. Use the "-u" option for this.


$ date -u
Wed, Jun 27, 2012  9:54:27 PM

Formatting

There are lot of formatting options available. As a guide you can use the following format to display everything from year to seconds.


$ date -u "+%Y-%m-%d %k:%M:%S"
2012-06-27 21:56:49

Published: Wednesday, 27 June 2012