Linux Date Command

In this post, we will show you some examples on how to use the date command in Linux. The date command in Linux can be used to print or set the system date and time. Using the Date Command in Linux its simple, just follow the examples and the syntax below. Let’s get started.

By default when running the date command in Linux, without any arguments it will display the current system date and time:

date

Sat 2 Dec 12:34:12 CST 2017

Syntax

Usage: date [OPTION]... [+FORMAT]
or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

Date examples

The following examples will show you how to use the date command to find the date and time from a period of time in the past or future.

1. Find the date 5 weeks in the future

date -d "5 weeks"
Sun Jan 7 19:53:50 CST 2018

2. Find the date 5 weeks and 4 days in the future

date -d "5 weeks 4 days"
Thu Jan 11 19:55:35 CST 2018

3. Get the next month date

date -d "next month"
Wed Jan 3 19:57:43 CST 2018

4. Get the last sunday date

date -d last-sunday
Sun Nov 26 00:00:00 CST 2017

The date command comes with various formatting option, the following examples will show you how to format the date command output.

Of course, if you use one of our VPS Hosting services, you can always contact and ask our expert Linux admins (via chat or ticket) about date command in linux and anything related to date examples on Linux. They are available 24×7 and will provide information or assistance immediately.

PS. If you liked this post on How to Use the Date Command in Linux please share it with your friends on the social networks using the buttons below or simply leave a reply. Thanks.