date

print or set the system date and time

copy
38
4
date +'%Y-%m-%d %H:%M:%S %z'Specify a date format that is independent of language and that does not use a time zone

details |

copy
12
1
date +%_d/%_m -d "Feb 1"This will remove the padding form the date field and add a space on the month field.

details |

copy
22
1
date -RDisplay the date and time using the format '%a, %d %b %Y %H:%M:%S %z'

details |

copy
12
1
date --date='TZ="Europe/Paris" 2008-10-31 07:30'Determine the date/time in Paris

details |

copy
12
1
date -u --date=2008-01-01 +%sAn alternative is to use the `--utc' (`-u') option. Then you may omit `UTC' from the date string. Although this produces the same result for `%s' and many other format sequences, with a time zone offset different from zero, it would give a different result for zone-dependent formats like `%z'.

details |

copy
4
0
date --iso-8601=ns | tr T ' 'without the tr the result would be 2009-03-12T17:51:30,347687841-0400

details |

copy
9
1
date -d 1may '+%B %-d'To print a date without the leading zero for one-digit days of the month, you can use the (GNU extension) `-' flag to suppress the padding altogether:

details |

copy
8
1
date --date='-1 month' +'Last month was %B?'What was the previous month?

details |

copy
8
1
date -d '1970-01-01 UTC 946684800 seconds' +"%Y-%m-%d %T %z"To convert such an unwieldy number of seconds back to a more readable form, use a command like this:

details |

copy
7
2
date --date='3 months 1 day'To print the date of the day three months and one day hence

details |

copy
4
0
date +%-d/%-m -d "Feb 1"This will remove the padding from the Date and Month field.

details |

copy
6
0
date --date='2 days ago'To print the date of the day before yesterday:

details |

copy
5
1
LC_ALL=C TZ=UTC0 datespecify a date format that is independent of language and that uses the time zone `UTC'

details |

copy
4
0
date +%d/%m -d "Feb 1"Unless otherwise specified, `date' normally pads numeric fields with zeros, so that, for example, numeric months are always output as two digits. Seconds since the epoch are not padded, though, since there is no natural width for them

details |

copy
7
1
date +%m%d%H%M%Y.%STo print the current date and time in the format required by many non-GNU versions of `date' when setting the system clock:

details |

copy
4
0
date --date="2005-02-27 14:19:13.489392193 +0530"Display the date and time specified in DATESTR instead of the current date and time. DATESTR can be in almost any common format.

details |

copy
9
1
date --date='25 Dec' +%jTo print the day of year of Christmas in the current year:

details |

copy
4
0
date +'@%s.%N'seconds since the epoch, i.e., since 1970-01-01 00:00:00 UTC.nanoseconds (`000000000'...`999999999')

details |