Date command

From Juneday education
Jump to: navigation, search


date - print or set the system date and time.

On this page we only give you a short introduction with a few examples. We encourage you to read the manual (man date).


Description

"In computer science and computer programming, system time represents a computer system's notion of the passing of time. In this sense, time also includes the passing of days on the calendar." System time

"In Unix-like operating systems, date is the command which will print or set the current time." Date command

Example output

 Mon May 23 06:56:45 UTC 2016
 Mon May 23 09:02:10 CEST 2016

Example usage

bash on GNU/Linux and cygwin

Convert seconds since the epoch (1970-01-01 UTC) to a date

             $ date --date='@2147483647'

Show the time on the west coast of the US (use tzselect(1) to find TZ)

             $ TZ='America/Los_Angeles' date

Show the local time for 9AM next Friday on the west coast of the US

             $ date --date='TZ="America/Los_Angeles" 09:00 next Fri'

bash on MacOS

The command:

          date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S"

will display:

          DATE: 1987-11-21
          TIME: 13:36:16

In the Europe/London timezone, the command:

          date -v1m -v+1y

will display:

          Sun Jan  4 04:15:24 GMT 1998

where it is currently Mon Aug 4 04:15:24 BST 1997.

The command:

          date -v1d -v3m -v0y -v-1d

will display the last day of February in the year 2000:

          Tue Feb 29 03:18:00 GMT 2000

So will do the command:

          date -v30d -v3m -v0y -v-1m

because there is no such date as the 30th of February.