

In addition to these use-cases, you can also control the output and use the formatting options available. So, when you get an invalid date error while using the date command, simply check the date format of your input.įor this, you get an output that should look like: :~$ date -d "" So, if you type something in a different order, you will encounter an error that should say this: :~$ date -d "25-08-1996" It is worth noting that the format for the input is YYYY-MM-DD. Suppose, you have a specific date but you want to display the weekday for that date, you need to specify the date using the -d flag as: date -d "" Here’s how it looks with the input and output: :~$ dateĪs you can see, it also shows the time zone along with the system time. To start with, you just need to enter the command “date” to display the date and time. Display the current date and time in Linux I have included some examples below which should give you some clarity on what I explained here. Here the option is essentially a flag like -d, – debug, etc which I’ll discuss in the later section of this article.Īnd, the format lets you control the output by adding your own string and specify the values you want in the output. Here’s the syntax of the date command: date In this article, we take a look at the date command in detail and what you can do with it using some examples. Yes, you can do a couple more things using the date command like identifying a week or day from a date, calculating the time from epoch to a specified time, and a few more variations.’ You can look into additional timedatectl command options by asking for help like this: $ timedatectl -h command.The date command in Linux is the simplest way to display the current time and date in Linux.īut, there’s more to it than meets the eye. There are 339 of them, so I prefer passing the command’s output to the column command: $ timedatectl list-timezones | wc -lĪfrica/Abidjan America/Paramaribo Asia/YekaterinburgĪfrica/Algiers America/Phoenix Asia/YerevanĪfrica/Bissau America/Port-au-Prince Atlantic/AzoresĪfrica/Cairo America/Porto_Velho Atlantic/BermudaĪfrica/Casablanca America/Puerto_Rico Atlantic/CanaryĪfrica/Ceuta America/Punta_Arenas Atlantic/Cape_VerdeĪfrica/El_Aaiun America/Rainy_River Atlantic/FaroeĪfrica/Johannesburg America/Rankin_Inlet Atlantic/MadeiraĪfrica/Juba America/Recife Atlantic/ReykjavikĪfrica/Khartoum America/Regina Atlantic/South_GeorgiaĪfrica/Lagos America/Resolute Atlantic/StanleyĪfrica/Maputo America/Rio_Branco Australia/AdelaideĪfrica/Monrovia America/Santarem Australia/BrisbaneĪfrica/Nairobi America/Santiago Australia/Broken_HillĪfrica/Ndjamena America/Santo_Domingo Australia/Darwin If you want to list the time zones, you can use the list-timezones option. You can change the time zone using sudo, but not the date or the time if your system clock is synchronized. = AUTHENTICATING FOR -timezone =Īuthentication is required to set the system timezone.Īuthenticating as: Sandra Henry-Stocker (shs) $ timedatectl set-timezone America/New_York <= no change, no authentication To change your settings, you need to use sudo.

If you move or take your laptop on vacation with you, however, you might want to make some changes to accommodate your new location. Time and date changes are seldom needed since your system generally manages this from the time of installation using NTP. In this case, the RTC it is not set to the local time zone. NTP is network time protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. The fields shown include the local time, universal time (the same around the globe), RTC (the real-time clock, usually an integrated circuit), and the time zone (America/New York” is the Eastern US time zone). You should see something like this: $ timedatectl To display the current settings, use the command by itself-with no arguments. The timedatectl command allows you to both query and change the system clock and its settings on Linux systems.
