How to change the date format?

0161

You can change the date format in the date command by using format specifiers. Here’s how to do it:

  1. Use the date command followed by the + sign and your desired format in quotes.

Here are some examples of custom date formats:

  • Standard format (YYYY-MM-DD HH:MM:SS):

    date "+%Y-%m-%d %H:%M:%S"
  • 12-hour clock format:

    date "+%I:%M:%S %p"
  • Including the day of the week:

    date "+%A, %B %d, %Y"
  • Compact date format:

    date "+%y%m%d"

You can experiment with these formats by typing them in your terminal. The + sign indicates that you are specifying a custom format. For a full list of formatting options, you can refer to the manual page by typing man date in the terminal.

0 Comments

no data
Be the first to share your comment!