How Do I Format a Date in Linux?
Contents
Date Format Option Meaning Example Output
date +%m-%d-%Y MM-DD-YYYY date format 05-09-2020
date +%D MM/DD/YY date format 05/09/20

What %D format in date command does?

We can modify the timestamp of a datefile by using touch command. 9: List of Format specifiers used with date command: %D: Display date as mm/dd/yy. %d: Display the day of the month (01 to 31).

How do I display only the date in Unix?

The date command under UNIX displays date and time. You can use the same command set date and time. You must be the super-user (root) to change the date and time on Unix like operating systems. The date command shows the date and time read from the kernel clock.

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest