{"id":14734,"date":"2023-08-03T06:46:15","date_gmt":"2023-08-03T06:46:15","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=14734"},"modified":"2024-01-18T12:09:18","modified_gmt":"2024-01-18T12:09:18","slug":"bash-date-format","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/","title":{"rendered":"How to Use Date Format in Bash [5 Examples]"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The <\/span><strong><a href=\"https:\/\/linuxsimply.com\/date-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">date command<\/a><\/strong><span style=\"font-weight: 400;\"> in <\/span><strong>Bash<\/strong><span style=\"font-weight: 400;\"> offers multiple different formats for printing dates in different ways. This article provides you with an extensive list of all the available formatting options while using the <\/span><strong>date<\/strong><span style=\"font-weight: 400;\"> command. Along with the list, I will show you a few examples to demonstrate how to use a date format in <strong>Bash<\/strong><\/span><span style=\"font-weight: 400;\"> to achieve the desired result.<\/span><\/p>\n<div class=\"su-youtube su-u-responsive-media-yes\"><iframe width=\"600\" height=\"400\" src=\"https:\/\/www.youtube.com\/embed\/PLqpTcLN9Us?\" frameborder=\"0\" allowfullscreen allow=\"autoplay; encrypted-media; picture-in-picture\" title=\"\"><\/iframe><\/div>\n<p><span style=\"font-weight: 400;\"><div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Practice-Files_bash-date-format.zip\" class=\"su-button su-button-style-default\" style=\"color:#000000;background-color:#E8F9FF;border-color:#bac8cc;border-radius:56px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#000000;padding:8px 26px;font-size:20px;line-height:30px;border-color:#effbff;border-radius:56px;text-shadow:0px 0px 0px #000000\"><i class=\"sui sui-download\" style=\"font-size:20px;color:#1AA1D6\"><\/i> Practice Files of Using Date Format in Bash<\/span><\/a><\/div><\/span><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#Different_Formatting_Options\" >Different Formatting Options<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#5_Practical_Examples_of_Using_Date_Format_in_Bash\" >5 Practical Examples of Using Date Format in Bash<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#1_Printing_Date_in_%E2%80%9CYYYY-MM-DD%E2%80%9D_Format\" >1. Printing Date in &#8220;YYYY-MM-DD&#8221; Format<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#2_Printing_Date_in_%E2%80%9CYY-MM-DD%E2%80%9D_Format\" >2. Printing Date in &#8220;YY-MM-DD&#8221; Format<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#3_Printing_Date_in_Weekday_Month_Day_Year_Format\" >3. Printing Date in Weekday, Month Day, Year Format<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#4_Printing_the_Day_of_the_Current_Week\" >4. Printing the Day of the Current Week<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#5_Printing_Date_in_24-Hour_Format\" >5. Printing Date in 24-Hour Format<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#Date_Formatting_Options\" >Date Formatting Options<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#People_Also_Ask\" >People Also Ask<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#How_to_set_date_format_in_shell_script\" >How to set date format in shell script?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#How_do_you_format_dates_in_bash\" >How do you format dates in bash?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#How_to_get_date_of_a_day_before_the_current_date\" >How to get date of a day before the current date?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#How_to_increment_a_day_in_Bash_script\" >How to increment a day in Bash script?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#Is_placing_the_format_specifiers_within_quotes_in_mandatory\" >Is placing the format specifiers within quotes in mandatory?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Different_Formatting_Options\"><\/span>Different Formatting Options<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The <\/span><b>date <\/b><span style=\"font-weight: 400;\">command prints the current date and time in the following format by default:<\/span><\/p>\n<p style=\"text-align: left;\"><b>\u2018<\/b><strong>Weekday_name Month_name Day_of_month Hour:Minutes:Seconds AM\/PM Timezone(HH) Year<\/strong><b>\u2019<\/b><span style=\"font-weight: 400;\">. For example, <\/span><strong>Tue Jul 11 12:14:01 PM +06 2023<\/strong><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">See the following output, when the <\/span><strong>date<\/strong> <span style=\"font-weight: 400;\">command is run in the<\/span> <strong>Ubuntu<\/strong><span style=\"font-weight: 400;\"> terminal:<\/span><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-14758\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.-Date-command.png\" alt=\"Executing the date command\" width=\"589\" height=\"116\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.-Date-command.png 589w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.-Date-command-300x59.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.-Date-command-767x151.png 767w\" sizes=\"(max-width: 589px) 100vw, 589px\" \/><span style=\"font-weight: 400;\"> To achieve similar output manually, you can use the following command with different date formats:<\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">date &quot;+%a %b %d %I:%M:%S %p %:::z %Y&quot;<\/code><\/pre>\n<p><span style=\"font-weight: 400;\"><div class=\"su-note\"  style=\"border-color:#cedfe2;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#E8F9FC;border-color:#ffffff;color:#333333;\"><\/span><\/p>\n<p style=\"text-align: justify;\"><strong>Note:<\/strong><span style=\"font-weight: 400;\"> Place a <\/span><strong>plus<\/strong><span style=\"font-weight: 400;\"> sign <\/span><strong>(+)<\/strong> <span style=\"font-weight: 400;\">before the formatting options. If multiple formatting options are in action, put them within <\/span><strong>quotes<\/strong><span style=\"font-weight: 400;\">. <\/div><\/div><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"su-note\"  style=\"border-color:#e5e3d9;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFFDF3;border-color:#ffffff;color:#333333;\"><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"> To know more about each formatting option of the command and other available formatting options, see the list of <a href=\"#Date-Formatting-Options\"><strong>Date Formatting Options<\/strong><\/a>. <\/div><\/div><\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"5_Practical_Examples_of_Using_Date_Format_in_Bash\"><\/span>5 Practical Examples of Using Date Format in Bash<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">At this point, I hope you are quite familiar with different <\/span><strong>formatting options<\/strong><span style=\"font-weight: 400;\">. Now, I am going to show how to use those options and print the date in the required formatting.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Printing_Date_in_%E2%80%9CYYYY-MM-DD%E2%80%9D_Format\"><\/span>1. Printing Date in &#8220;YYYY-MM-DD&#8221; Format<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">This first example is for making you more familiar with the format specifiers such as <\/span><strong>%Y<\/strong> <span style=\"font-weight: 400;\">and <\/span><strong>%d<\/strong><span style=\"font-weight: 400;\">. These format specifiers are useful for printing dates in <\/span><strong>YYYY-MM-DD<\/strong> <span style=\"font-weight: 400;\">format.<\/span><\/p>\n<p>To print date in YYYY-MM-DD format, use the following Bash script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\ntoday=$(date +%Y-%m-%d)\necho $today<\/code><\/pre>\n<p><span style=\"font-weight: 400;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\"><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The script utilizes the format <\/span><code class=\"\" data-line=\"\">%Y<\/code><span style=\"font-weight: 400;\">\u00a0to retrieve the full year (<\/span><strong>YYYY<\/strong><span style=\"font-weight: 400;\">), <\/span><code class=\"\" data-line=\"\">%m<\/code><span style=\"font-weight: 400;\">\u00a0for the month (<\/span><strong>MM<\/strong><span style=\"font-weight: 400;\">), and <\/span><code class=\"\" data-line=\"\">%d<\/code><span style=\"font-weight: 400;\">\u00a0for the day (<\/span><strong>DD<\/strong><span style=\"font-weight: 400;\">). After substituting the <\/span><strong>date<\/strong><span style=\"font-weight: 400;\"> command in the variable &#8220;<\/span>today<span style=\"font-weight: 400;\">&#8220;, it outputs the value of the variable using the <\/span><strong><a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/input-output\/output\/echo-command\/\" target=\"_blank\" rel=\"noopener\">echo command<\/a><\/strong><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\"><\/div><\/div><img decoding=\"async\" class=\"aligncenter wp-image-14761 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Run-script.png\" alt=\"Printing date in &quot;YYYY-MM-DD&quot; format\" width=\"599\" height=\"115\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Run-script.png 599w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Run-script-300x58.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Run-script-766x147.png 766w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/span><span style=\"font-weight: 400;\">The script prints today&#8217;s date <\/span><strong style=\"font-size: inherit;\">2023-07-11<\/strong> <span style=\"font-weight: 400;\">in the expected format.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"su-note\"  style=\"border-color:#cedfe2;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#E8F9FC;border-color:#ffffff;color:#333333;\"><\/span><\/p>\n<p style=\"text-align: justify;\"><strong>Note:<\/strong><span style=\"font-weight: 400;\"> Instead of using multiple format specifiers, you can use <\/span><strong>%F<\/strong> <span style=\"font-weight: 400;\">format to print the date in <\/span><strong>YYYY-MM-DD<\/strong> <span style=\"font-weight: 400;\">format<\/div><\/div><\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Printing_Date_in_%E2%80%9CYY-MM-DD%E2%80%9D_Format\"><\/span>2. Printing Date in &#8220;YY-MM-DD&#8221; Format<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In this example, I am going to run a <\/span><strong>Bash<\/strong> <span style=\"font-weight: 400;\">script that will ultimately print the date in <\/span><strong>YY-MM-DD<\/strong> <span style=\"font-weight: 400;\">format. Check the following bash script for the practical approach:<\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\ntoday=$(date +%y-%m-%d)\necho $today<\/code><\/pre>\n<p><span style=\"font-weight: 400;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\"><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The script utilizes the format <\/span><code class=\"\" data-line=\"\">%y<\/code><span style=\"font-weight: 400;\">\u00a0to retrieve year (<\/span><strong>YY<\/strong><span style=\"font-weight: 400;\">), <\/span><code class=\"\" data-line=\"\">%m<\/code><span style=\"font-weight: 400;\">\u00a0for the month (<\/span><strong>MM<\/strong><span style=\"font-weight: 400;\">) and <\/span><code class=\"\" data-line=\"\">%d<\/code><span style=\"font-weight: 400;\">\u00a0for the day (<\/span><strong>DD<\/strong><span style=\"font-weight: 400;\">). After substituting the <\/span><strong>date<\/strong><span style=\"font-weight: 400;\"> command in the variable &#8220;<\/span>today<span style=\"font-weight: 400;\">&#8220;, it outputs the value of the variable using the <\/span><strong>echo<\/strong><span style=\"font-weight: 400;\"> command. <\/span><span style=\"font-weight: 400;\"><\/div><\/div><\/span><\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-14762\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-YY-MM-DD-format.png\" alt=\"YY-MM-DD format of date\" width=\"562\" height=\"112\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-YY-MM-DD-format.png 562w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-YY-MM-DD-format-300x60.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-YY-MM-DD-format-768x153.png 768w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><span style=\"font-weight: 400;\">The program prints the current date <\/span><strong>23-07-11<\/strong><span style=\"font-weight: 400;\"> as specified by the <\/span><strong>format specifiers<\/strong><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Printing_Date_in_Weekday_Month_Day_Year_Format\"><\/span>3. Printing Date in Weekday, Month Day, Year Format<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Now, I want to print the date in a customized format where weekday and year should be separated by a <\/span><strong>comma (,)<\/strong><span style=\"font-weight: 400;\">. You can also achieve this using format specifiers of the following script:<\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\ntoday=$(date \u201c+%A, %B-%d, %Y\u201d)\necho $today<\/code><\/pre>\n<p><span style=\"font-weight: 400;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\"><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The script specifies the format <\/span><code class=\"\" data-line=\"\">%A<\/code><span style=\"font-weight: 400;\">\u00a0to get the full name of the <\/span><strong>weekday<\/strong><span style=\"font-weight: 400;\">. Then <\/span><code class=\"\" data-line=\"\">%B<\/code><span style=\"font-weight: 400;\">\u00a0and <\/span><code class=\"\" data-line=\"\">%d<\/code> <span style=\"font-weight: 400;\">to get the full name of the <\/span><strong>month<\/strong><span style=\"font-weight: 400;\"> and <\/span><strong>day of the month<\/strong> <span style=\"font-weight: 400;\">separated by a <\/span><strong>hyphen (-)<\/strong><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Finally, to get the full year (<\/span><strong>YYYY<\/strong><span style=\"font-weight: 400;\">) it uses the format specifiers <\/span><code class=\"\" data-line=\"\">%Y<\/code><span style=\"font-weight: 400;\">. After substituting the <\/span><strong>date<\/strong><span style=\"font-weight: 400;\"> command in the variable &#8220;<\/span>today<span style=\"font-weight: 400;\">&#8220;, it outputs the value of the variable using the <\/span><strong>echo<\/strong><span style=\"font-weight: 400;\"> command. <\/span><span style=\"font-weight: 400;\"><\/div><\/div><\/span><\/p>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14763\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/6.-Full-name-format.png\" alt=\"Printing full name of month\" width=\"592\" height=\"117\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/6.-Full-name-format.png 592w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/6.-Full-name-format-300x59.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/6.-Full-name-format-764x151.png 764w\" sizes=\"(max-width: 592px) 100vw, 592px\" \/><span style=\"font-weight: 400;\">After executing the script, it displays the current date in the following format: <\/span><strong>Tuesday, July-11, 2023<\/strong><span style=\"font-weight: 400;\">. The output includes the <\/span><strong>weekday<\/strong><span style=\"font-weight: 400;\">, the <\/span><strong>month with the day<\/strong> <span style=\"font-weight: 400;\">of the month, and the <\/span><strong>year<\/strong><span style=\"font-weight: 400;\">, with each item separated by a <\/span><strong>comma<\/strong><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"4_Printing_the_Day_of_the_Current_Week\"><\/span>4. Printing the Day of the Current Week<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Using the format specifiers of the <\/span><strong>date<\/strong><span style=\"font-weight: 400;\"> command you can print the day of the current week. The\u00a0 <\/span><strong>%u<\/strong> <span style=\"font-weight: 400;\">format specifier starts counting days of the current week from <\/span><strong>Monday<\/strong><span style=\"font-weight: 400;\">. So, <\/span><strong>Monday<\/strong><span style=\"font-weight: 400;\"> is <\/span><strong>day 1<\/strong> <span style=\"font-weight: 400;\">of the current week.<\/span><\/p>\n<p>To print the day of the current week, use the following bash script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash \n\ntoday=$(date +%u) \necho \u201cDay of the week is: $today\u201d<\/code><\/pre>\n<p><span style=\"font-weight: 400;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\"><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The script utilizes <\/span><code class=\"\" data-line=\"\">%u<\/code> <span style=\"font-weight: 400;\">to get the day of the current week. After substituting the <\/span><strong>date<\/strong><span style=\"font-weight: 400;\"> command in the variable &#8220;<\/span>today<span style=\"font-weight: 400;\">&#8220;, it outputs the value of the variable using the <\/span><strong>echo<\/strong><span style=\"font-weight: 400;\"> command.<\/span><span style=\"font-weight: 400;\"><\/div><\/div><\/span><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14764\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/7.-Day-of-the-week.png\" alt=\"Printing day the week using date format\" width=\"574\" height=\"118\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/7.-Day-of-the-week.png 574w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/7.-Day-of-the-week-300x62.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/7.-Day-of-the-week-764x157.png 764w\" sizes=\"(max-width: 574px) 100vw, 574px\" \/><span style=\"font-weight: 400;\">After executing the script, it shows the <\/span><strong>Day of the week<\/strong> <span style=\"font-weight: 400;\">is <\/span><strong>2<\/strong><span style=\"font-weight: 400;\">. As the <\/span><strong>%u<\/strong><span style=\"font-weight: 400;\">\u00a0format specifier starts counting days of the week from <\/span><strong>Monday<\/strong><span style=\"font-weight: 400;\">, <\/span><strong>2<\/strong> <span style=\"font-weight: 400;\">means <\/span><strong>Tuesday<\/strong><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"5_Printing_Date_in_24-Hour_Format\"><\/span>5. Printing Date in 24-Hour Format<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">While printing date someone may stumble in printing <\/span><strong>time<\/strong><span style=\"font-weight: 400;\"> in <\/span><strong>24-hour<\/strong><span style=\"font-weight: 400;\"> format. Here is how you can use the <\/span><strong>date<\/strong> <span style=\"font-weight: 400;\">command to print time in <\/span><strong>24-hour<\/strong><span style=\"font-weight: 400;\"> format:<\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nc_time=$(date +%H:%M:%S)\necho $c_time<\/code><\/pre>\n<p><span style=\"font-weight: 400;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\"><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The script utilizes the format <\/span><code class=\"\" data-line=\"\">%H<\/code><span style=\"font-weight: 400;\">\u00a0to retrieve the current hour in<\/span> <strong>24-hour<\/strong><span style=\"font-weight: 400;\"> format, <\/span><code class=\"\" data-line=\"\">%M<\/code><span style=\"font-weight: 400;\">\u00a0for <\/span><strong>minutes,<\/strong><span style=\"font-weight: 400;\"> and <\/span><code class=\"\" data-line=\"\">%S<\/code><span style=\"font-weight: 400;\">\u00a0for running <\/span><strong>second<\/strong><span style=\"font-weight: 400;\">. After substituting the <\/span><strong>date<\/strong><span style=\"font-weight: 400;\"> command in the variable &#8220;<\/span>c_time<span style=\"font-weight: 400;\">&#8220;, it outputs the variable&#8217;s value using the <\/span><strong>echo<\/strong> <span style=\"font-weight: 400;\">command.<\/span><span style=\"font-weight: 400;\"><\/div><\/div><\/span><\/p>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14765\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/8.-24-hour-format.png\" alt=\"24 hour time format in Bash\" width=\"546\" height=\"126\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/8.-24-hour-format.png 546w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/8.-24-hour-format-300x69.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/8.-24-hour-format-767x177.png 767w\" sizes=\"(max-width: 546px) 100vw, 546px\" \/><span style=\"font-weight: 400;\">When executing the program shows the current time <\/span><strong>17:25:14<\/strong><span style=\"font-weight: 400;\"> in a <\/span><strong>24-hour<\/strong><span style=\"font-weight: 400;\"> time format.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Date_Formatting_Options\"><\/span><a id=\"Date-Formatting-Options\"><\/a>Date Formatting Options<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Apart from the examples in this article, you can achieve the desired <\/span><strong>date format<\/strong> <span style=\"font-weight: 400;\">using the wide variety of <\/span><strong>format specifiers<\/strong><span style=\"font-weight: 400;\"> given in the table below:<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"su-table su-table-responsive su-table-alternate su-table-fixed\"><\/span><\/p>\n<table style=\"width: 100%\">\n<tbody>\n<tr>\n<th style=\"width: 6.64336%\"><strong>Format<\/strong><\/th>\n<th style=\"width: 45.6876%\"><b>Description<\/b><\/th>\n<th style=\"width: 20.1632%\"><b>Example code<\/b><\/th>\n<th style=\"width: 26.4569%\"><b>Sample Output<\/b><\/th>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%%<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">A literal<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%%<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">%<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%a<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Locale\u2019s weekday name in shorter form; Such as Sun<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%a<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">Sun<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%A<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Locale\u2019s full weekday name; Such as Sunday<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%A<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">Sunday<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%b<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Locale\u2019s month name in shorter form<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%b<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">Jun<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%B<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Locale\u2019s full month name<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%B<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">June<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%c<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Locale\u2019s date and time<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%c<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">Sun 18 Jun 2023 12:18:40 PM +06<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%C<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">century<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%C<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">20<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%e<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Day of month<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%e<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">18<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%F<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Full date; same as %Y-%m-%d<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%F<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">2023-06-18<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%g<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Last two digits of the year of ISO week number<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%g<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">23<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%G<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">year of ISO week number<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%G<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">2023<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%d<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Day of month<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%d<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">18<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%D<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Date; same as %m\/%d\/%y<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%D<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">06\/18\/23<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%H<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Hour<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%H<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">11<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%I<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Hour<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%I<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">11<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%j<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Day of year<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%j<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">169<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%m<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Month of year<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%m<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">06<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%M<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Minute(00 to 59)\u00a0<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%M<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">32<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%r<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Locale\u2019s 12-hour clock time<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%r<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">11:12:14 AM<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%q<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Quarter of a year<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%q<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">2<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%s<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">seconds since 1970-01-01 00:00:00 UTC<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%s<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">1687068749<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%S<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">seconds(00 to 60)<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%S<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">50<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%t<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">A tab<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%t<\/span><\/td>\n<td style=\"width: 26.4569%\"><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%T<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Time as same as %H:%M:%S<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%T<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">12:10:13<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%u<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Day of week(1 to 7); 1 is Monday<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%u<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">7<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%U<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Week number of the year(0 to 53); Sunday as first day of week<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%U<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">25<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%V<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">ISO week number of the year(0 to 53); Monday as the first day of week<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%V<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">24<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%w<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Day of week(0 to 6); 0 is sunday<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%w<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">0<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%W<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Week of year(0 to 53); Monday as firstday of the week<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%W<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">24<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%x<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Locale\u2019s date representation<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%x<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">06\/18\/2023<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%X<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Locale\u2019s time representation<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%X<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">12:04:10 PM<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%y<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Last two digits of year<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%y<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">23<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%Y<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Full year<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%Y<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">23<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%z<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">+hhmm numeric time zone<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%z<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">+0600<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%:z<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">+hh:mm numeric time zone<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%:z<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">+06:00<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%::z<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">+hh:mm:ss numeric time zone<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%::z<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">+06:00:00<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%:::z<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">numeric time zone with : to necessary precision(+06, -05:30)<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%:::z<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">+06<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 6.64336%\"><strong>%Z<\/strong><\/td>\n<td style=\"width: 45.6876%\"><span style=\"font-weight: 400\">Time zone abbreviation\u00a0<\/span><\/td>\n<td style=\"width: 20.1632%\"><span style=\"font-weight: 400\">$ date +%Z<\/span><\/td>\n<td style=\"width: 26.4569%\"><span style=\"font-weight: 400\">+06<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400\"><\/div><\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In conclusion, the <\/span><strong>date<\/strong><span style=\"font-weight: 400;\"> command in <\/span><strong>Bash<\/strong> <span style=\"font-weight: 400;\">is useful for printing dates and times. One can use different format specifiers along with the <\/span><strong>date<\/strong><span style=\"font-weight: 400;\"> command to display or format the date as per requirement.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"People_Also_Ask\"><\/span>People Also Ask<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"How_to_set_date_format_in_shell_script\"><\/span>How to set date format in shell script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">To set the date format in a shell script, you can use the date command with its different formatting characters. The most common of these characters are:<\/p>\n<ul>\n<li><strong>%D:<\/strong> Date; same as %m\/%d\/%y<\/li>\n<li><strong>%H:<\/strong> Hour<\/li>\n<li><strong>%j:<\/strong> Day of year<\/li>\n<li><strong>%m:<\/strong> Month of year<\/li>\n<li><strong>%M:<\/strong> Minute(00 to 59)<\/li>\n<li><strong>%s:<\/strong> seconds since 1970-01-01 00:00:00 UTC<\/li>\n<li><strong>%S:<\/strong> seconds(00 to 60)<\/li>\n<li><strong>%u:<\/strong> Day of week(1 to 7); 1 is Monday<\/li>\n<li><strong>%U:<\/strong> Week number of the year(0 to 53); Sunday as first day of week<\/li>\n<li><strong>%y:<\/strong> Last two digits of the year.<\/li>\n<li><strong>%Y:<\/strong> Full year<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"How_do_you_format_dates_in_bash\"><\/span>How do you format dates in bash?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">By using the date command, along with a specified format string, you can format dates in Bash. For example, executing <code class=\"\" data-line=\"\">date +%Y-%m-%d<\/code> will display the current date formatted as <code class=\"\" data-line=\"\">YYYY-MM-DD<\/code>.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_to_get_date_of_a_day_before_the_current_date\"><\/span>How to get date of a day before the current date?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">To get the date of a day before, use &#8216;<strong>yesterday&#8217; <\/strong>or &#8216;<strong>1 day ago&#8217;<\/strong>\u00a0with the <strong>date <\/strong>command along with command option <code class=\"\" data-line=\"\">-d<\/code>. Use the syntax, <code class=\"\" data-line=\"\">date -d &quot;yesterday&quot; &quot;+%Y-%m-%d&quot;<\/code>.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_to_increment_a_day_in_Bash_script\"><\/span>How to increment a day in Bash script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">To increment a day from a specific date use <code class=\"\" data-line=\"\">+1 day<\/code> with the <strong>date <\/strong>command along with the <code class=\"\" data-line=\"\">-d<\/code> option.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Is_placing_the_format_specifiers_within_quotes_in_mandatory\"><\/span>Is placing the format specifiers within quotes in mandatory?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><strong>No<\/strong>. If you use <strong>single <\/strong>format specifiers you don\u2019t need to place the specifier within quotes. However, when you use <strong>multiple <\/strong>specifiers at a time you need to put those specifiers within a single or double quote.<\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"How do you format dates in bash?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"By using the date command, along with a specified format string, you can format dates in Bash. For example, executing date +%Y-%m-%d will display the current date formatted as YYYY-MM-DD.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"How to get date of a day before the current date?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"To get the date of a day before, use 'yesterday' or '1 day ago'\u00a0with the date command along with command option -d. Use the syntax, date -d \\\"yesterday\\\" \\\"+%Y-%m-%d\\\".\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"How to increment a day in Bash script?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"To increment a day from a specific date use +1 day with the date command along with the -d option.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Is placing the format specifiers within quotes in mandatory?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"No. If you use single format specifiers you don\u2019t need to place the specifier within quotes. However, when you use multiple specifiers at a time you need to put those specifiers within a single or double quote.\"\n    }\n  }]\n}\n<\/script><\/p>\n<p><span style=\"font-size: 18pt; color: #003366;\"><strong>Related Articles<\/strong><\/span><\/p>\n<ul>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-date\/\" target=\"_blank\" rel=\"noopener\">How to Get Date in Bash [2 Methods with Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/print-time\/\" target=\"_blank\" rel=\"noopener\">How to Print Time in Bash [2 Quick Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/list-users\/\" target=\"_blank\" rel=\"noopener\">How to List Users in Bash [2 Easy Ways]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/current-time\/\" target=\"_blank\" rel=\"noopener\">How to Get Current Time in Bash [4 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-timestamp\/\" target=\"_blank\" rel=\"noopener\">How to Get Timestamp in Bash [2 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/copy-paste\/\" target=\"_blank\" rel=\"noopener\">How to Copy and Paste in Bash [2 Methods &amp; Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/read-password\/\" target=\"_blank\" rel=\"noopener\">How to Read Password in Bash [3 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/send-email\/\" target=\"_blank\" rel=\"noopener\">How to Send Email in Bash [2 Easy Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/send-email-with-attachment\/\" target=\"_blank\" rel=\"noopener\">Bash Script to Send Email with Attachment [Step-by-Step Guide]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-ip-address\/\" target=\"_blank\" rel=\"noopener\">How to Get IP Address in Bash [3 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/find-and-replace\/\" target=\"_blank\" rel=\"noopener\">How to Find and Replace String in Bash [5 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/\" target=\"_blank\" rel=\"noopener\">How to Get Script Name Using Bash Script? [3 Easy Ways]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/call-another-script\/\" target=\"_blank\" rel=\"noopener\">How to Call Another Script in Bash [2 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/generate-uuid\/\" target=\"_blank\" rel=\"noopener\">How to Generate UUID in Bash [3 Simple Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/write-to-file\/\" target=\"_blank\" rel=\"noopener\">3 Easy Ways to Write to a File in Bash Script<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/output-to-file\/\" target=\"_blank\" rel=\"noopener\">How to Write the Output to a File in Bash Script [5 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/list-in-bash\/\" target=\"_blank\" rel=\"noopener\">How to Create a List in Bash Scripts? [2 Easy Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/clear-history\/\" target=\"_blank\" rel=\"noopener\">How to Clear History in Bash [2 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/clear-screen\/\" target=\"_blank\" rel=\"noopener\">How to Clear Screen Using Bash Script? [2 Effective Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/check-ubuntu-version\/\" target=\"_blank\" rel=\"noopener\">How to Check Ubuntu Version Using Bash Scripts? [2 Methods]<\/a><\/strong><\/li>\n<\/ul>\n<hr \/>\n<p><strong>&lt;&lt; Go Back to <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;28 Essential Bash Script Examples&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1065857,&quot;3&quot;:{&quot;1&quot;:0},&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/\" target=\"_blank\" rel=\"noopener\">Bash Script Examples<\/a> <\/span>| <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Scripting Basics&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:16768,&quot;10&quot;:1,&quot;11&quot;:4,&quot;17&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Basics<\/a><\/span>\u00a0| <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Tutorial<\/a><\/strong><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-center kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;center&quot;,&quot;id&quot;:&quot;14734&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;How to Use Date Format in Bash [5 Examples]&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\">Rate this post<\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>The date command in Bash offers multiple different formats for printing dates in different ways. This article provides you with &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Use Date Format in Bash [5 Examples]\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#more-14734\" aria-label=\"Read more about How to Use Date Format in Bash [5 Examples]\">Read more<\/a><\/p>\n","protected":false},"author":314903,"featured_media":14766,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[114],"class_list":["post-14734","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-scripting","tag-bash-script-examples","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Use Date Format in Bash [5 Examples]<\/title>\n<meta name=\"description\" content=\"In Bash, there are a lot of date format. Depending on the circumstances, these formats can be used to print dates in various ways.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use Date Format in Bash [5 Examples]\" \/>\n<meta property=\"og:description\" content=\"In Bash, there are a lot of date format. Depending on the circumstances, these formats can be used to print dates in various ways.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/zahidlaku72\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-03T06:46:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-18T12:09:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/Bash-date-format-.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Md Zahidul Islam Laku\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Md Zahidul Islam Laku\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/\"},\"author\":{\"name\":\"Md Zahidul Islam Laku\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/26b37b2c7517d2c8702472bc3986ef21\"},\"headline\":\"How to Use Date Format in Bash [5 Examples]\",\"datePublished\":\"2023-08-03T06:46:15+00:00\",\"dateModified\":\"2024-01-18T12:09:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/\"},\"wordCount\":1744,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Bash-date-format-.png\",\"keywords\":[\"bash script examples\"],\"articleSection\":[\"Bash Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/\",\"name\":\"How to Use Date Format in Bash [5 Examples]\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Bash-date-format-.png\",\"datePublished\":\"2023-08-03T06:46:15+00:00\",\"dateModified\":\"2024-01-18T12:09:18+00:00\",\"description\":\"In Bash, there are a lot of date format. Depending on the circumstances, these formats can be used to print dates in various ways.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Bash-date-format-.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Bash-date-format-.png\",\"width\":400,\"height\":400,\"caption\":\"Date format in Bash\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/date-format\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bash Scripting Tutorial\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bash Scripting Basics\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Bash Script Examples\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"How to Use Date Format in Bash [5 Examples]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"name\":\"LinuxSimply\",\"description\":\"All About Linux\",\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/linuxsimply.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\",\"name\":\"LinuxSimply\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"width\":355,\"height\":48,\"caption\":\"LinuxSimply\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/26b37b2c7517d2c8702472bc3986ef21\",\"name\":\"Md Zahidul Islam Laku\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Md-Zahidul-Islam-Laku-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Md-Zahidul-Islam-Laku-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Md-Zahidul-Islam-Laku-II-96x96.png\",\"caption\":\"Md Zahidul Islam Laku\"},\"description\":\"Hey, I'm Zahidul Islam Laku currently working as a Linux Content Developer Executive at SOFTEKO. I completed my graduation from Bangladesh University of Engineering and Technology (BUET). I write articles on a variety of tech topics including Linux. Learning and writing on Linux is nothing but fun as it gives me more power on my machine. What can be more efficient than interacting with the Operating System without Graphical User Interface! Read Full Bio\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/zahidlaku72\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/zahidlaku\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCnxMIaAb-nXO5XnMeEaNhpQ\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/laku\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Use Date Format in Bash [5 Examples]","description":"In Bash, there are a lot of date format. Depending on the circumstances, these formats can be used to print dates in various ways.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/","og_locale":"en_US","og_type":"article","og_title":"How to Use Date Format in Bash [5 Examples]","og_description":"In Bash, there are a lot of date format. Depending on the circumstances, these formats can be used to print dates in various ways.","og_url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/zahidlaku72","article_published_time":"2023-08-03T06:46:15+00:00","article_modified_time":"2024-01-18T12:09:18+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/Bash-date-format-.png","type":"image\/png"}],"author":"Md Zahidul Islam Laku","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Md Zahidul Islam Laku","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/"},"author":{"name":"Md Zahidul Islam Laku","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/26b37b2c7517d2c8702472bc3986ef21"},"headline":"How to Use Date Format in Bash [5 Examples]","datePublished":"2023-08-03T06:46:15+00:00","dateModified":"2024-01-18T12:09:18+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/"},"wordCount":1744,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/Bash-date-format-.png","keywords":["bash script examples"],"articleSection":["Bash Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/","url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/","name":"How to Use Date Format in Bash [5 Examples]","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/Bash-date-format-.png","datePublished":"2023-08-03T06:46:15+00:00","dateModified":"2024-01-18T12:09:18+00:00","description":"In Bash, there are a lot of date format. Depending on the circumstances, these formats can be used to print dates in various ways.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/Bash-date-format-.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/Bash-date-format-.png","width":400,"height":400,"caption":"Date format in Bash"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxsimply.com\/"},{"@type":"ListItem","position":2,"name":"Bash Scripting Tutorial","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/"},{"@type":"ListItem","position":3,"name":"Bash Scripting Basics","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/"},{"@type":"ListItem","position":4,"name":"Bash Script Examples","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/"},{"@type":"ListItem","position":5,"name":"How to Use Date Format in Bash [5 Examples]"}]},{"@type":"WebSite","@id":"https:\/\/linuxsimply.com\/#website","url":"https:\/\/linuxsimply.com\/","name":"LinuxSimply","description":"All About Linux","publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxsimply.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxsimply.com\/#organization","name":"LinuxSimply","url":"https:\/\/linuxsimply.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","width":355,"height":48,"caption":"LinuxSimply"},"image":{"@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/26b37b2c7517d2c8702472bc3986ef21","name":"Md Zahidul Islam Laku","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Md-Zahidul-Islam-Laku-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Md-Zahidul-Islam-Laku-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Md-Zahidul-Islam-Laku-II-96x96.png","caption":"Md Zahidul Islam Laku"},"description":"Hey, I'm Zahidul Islam Laku currently working as a Linux Content Developer Executive at SOFTEKO. I completed my graduation from Bangladesh University of Engineering and Technology (BUET). I write articles on a variety of tech topics including Linux. Learning and writing on Linux is nothing but fun as it gives me more power on my machine. What can be more efficient than interacting with the Operating System without Graphical User Interface! Read Full Bio","sameAs":["https:\/\/www.facebook.com\/zahidlaku72","https:\/\/www.linkedin.com\/in\/zahidlaku\/","https:\/\/www.youtube.com\/channel\/UCnxMIaAb-nXO5XnMeEaNhpQ"],"url":"https:\/\/linuxsimply.com\/author\/laku\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/14734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/users\/314903"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=14734"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/14734\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/14766"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=14734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=14734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=14734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}