{"id":1436,"date":"2021-12-16T00:00:13","date_gmt":"2021-12-15T18:30:13","guid":{"rendered":"https:\/\/smarttech101.com\/?p=1436"},"modified":"2022-11-12T02:12:32","modified_gmt":"2022-11-11T20:42:32","slug":"date-command-in-linux-unix-with-practical-examples","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/","title":{"rendered":"Date Command in Linux\/Unix with Practical Examples"},"content":{"rendered":"\n<p>The date command in Linux\/Unix, although seemingly simple, has many applications &#8211; creating unique names to use with logfiles and screenshots, energy-efficient alarm clock, finding times in different time zones, finding date 1 year before today, converting Unix Timestamps to DateTime format or any other formats, finding the last modified time of a file, and many more. In this article, I will talk about all features of the date command using such applications. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"table-of-contents\">Table of Contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"#1-how-to-get-current-date-and-time-using-date-command-in-linux\">1. How to Get Current Date and Time Using Date Command in Linux<\/a><\/li><li><a href=\"#2-how-to-get-current-time-and-date-in-given-formats-using-date-command-in-linux\">2. How to Get Current Time and Date in Given Formats Using Date Command in Linux<\/a><ul><li><a href=\"#2-1-example-1-creating-unique-filename\">2.1. Example 1. Creating Unique Filename<\/a><\/li><li><a href=\"#2-2-example-2-creating-clock-for-tiling-window-managers\">2.2. Example 2: Creating Clock for Tiling Window Managers<\/a><\/li><\/ul><\/li><li><a href=\"#3-how-to-print-a-given-time-instead-of-the-current-time-using-date-command-in-linux\">3. How to Print a Given Time Instead of the Current Time Using Date Command in Linux<\/a><\/li><li><a href=\"#4-how-to-convert-dates-from-one-format-to-another-using-date-command-in-linux\">4. How to Convert Dates from One Format to Another Using Date Command in Linux<\/a><\/li><li><a href=\"#5-convert-unix-timestamp-to-date-and-vice-versa-using-date-command-in-linux\">5. Convert Unix Timestamp to Date and Vice-Versa Using Date Command in Linux<\/a><ul><li><a href=\"#5-1-unix-timestamp\">5.1. Unix Timestamp<\/a><\/li><li><a href=\"#5-2-date-to-unix-timestamp\">5.2. Date to Unix Timestamp<\/a><\/li><li><a href=\"#5-3-unix-timestamp-to-date\">5.3. Unix Timestamp to Date<\/a><\/li><\/ul><\/li><li><a href=\"#6-how-to-get-last-modified-time-of-a-file-using-date-command-in-linux\">6. How to Get Last Modified Time of a File Using Date Command in Linux<\/a><\/li><li><a href=\"#7-how-to-get-times-in-different-time-zone-using-date-command-in-linux\">7. How to Get Times in Different Time Zone Using Date Command in Linux<\/a><\/li><li><a href=\"#8-conclusion\">8. Conclusion<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-how-to-get-current-date-and-time-using-date-command-in-linux\">1. How to Get Current Date and Time Using Date Command in Linux<\/h2>\n\n\n\n<p>One problem I very often face while booting back and forth between Windows and Linux in my dual-boot PC is that the current time gets changed. While fixing this up, I use the <strong>date<\/strong> command very often.<\/p>\n\n\n\n<p><strong>Syntax<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Tue Dec 14 02:54:05 AM IST 2021<\/code><\/pre>\n\n\n\n<p>Combining the above command with the <strong>watch<\/strong> command you can even create a <strong>digital clock<\/strong> that will print the date and time at every second \ud83d\ude01:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ watch --interval=1 date<\/code><\/pre>\n\n\n\n<p>You can also get the Coordinated Universal Time (UTC) using -u or &#8211;utc or &#8211;universal flag:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date --utc<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Mon Dec 13 09:25:50 PM UTC 2021<\/code><\/pre>\n\n\n\n<p>In the above examples, as you are seeing, the outputs are in a special order &#8211; first weekday (Mon), then the year (Dec), then the day of the month (13), and so on. We can change this order of output and that will be described in the next heading.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-how-to-get-current-time-and-date-in-given-formats-using-date-command-in-linux\">2. How to Get Current Time and Date in Given Formats Using Date Command in Linux<\/h2>\n\n\n\n<p>To change the output format, we use special sequences. The following sequences are sufficient to fulfill most of your needs:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>Format Sequences<\/th><th>Interpretation<\/th><\/tr><\/thead><tbody><tr><td>%a<\/td><td>abbreviated weekday name (e.g., Sun)<\/td><\/tr><tr><td>%A<\/td><td>full weekday name (e.g., Sunday)<\/td><\/tr><tr><td>%b<\/td><td>abbreviated month name (e.g., Jan)<\/td><\/tr><tr><td>%B<\/td><td>full month name (e.g., January)<\/td><\/tr><tr><td>%d<\/td><td>day of the month (e.g., 01)<\/td><\/tr><tr><td>%H<\/td><td>hour (e.g., 00..23)<\/td><\/tr><tr><td>%I<\/td><td>hour (e.g., 01..12)<\/td><\/tr><tr><td>%m<\/td><td>month (01..12)<\/td><\/tr><tr><td>%M<\/td><td>minute (00..59)<\/td><\/tr><tr><td>%Y<\/td><td>year<\/td><\/tr><tr><td><strong>%N<\/strong><\/td><td><strong>nanoseconds (000000000..999999999)<\/strong><\/td><\/tr><tr><td>%p<\/td><td>AM or PM<\/td><\/tr><tr><td>%P<\/td><td>am or pm<\/td><\/tr><tr><td><strong>%s<\/strong><\/td><td><strong>seconds since the Epoch (1970-01-01 00:00 UTC)<\/strong><\/td><\/tr><tr><td>%S<\/td><td>second (00..60)<\/td><\/tr><tr><td>%u<\/td><td>day of the week (1..7); 1 is Monday<\/td><\/tr><\/tbody><\/table><figcaption>Table: Date Sequences and Their Interpretation; Source: <code>man date<\/code><\/figcaption><\/figure>\n\n\n\n<p>There are more such sequences. To learn about them, see the man page.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date +FORMAT<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-1-example-1-creating-unique-filename\">2.1. Example 1. Creating Unique Filename<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date '+%Y-%m-%d_%T.%N'<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2021-12-20_23:11:42.983703647<\/code><\/pre>\n\n\n\n<p>My screenshot command is based on the above example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ import \"$(date '+%Y-%m-%d_%T.%N').png\"<\/code><\/pre>\n\n\n\n<p>Here <strong>import<\/strong><code><strong> <\/strong><\/code>is a screenshot tool included in the package <strong>imagemagick<\/strong> and<code> \"$(date '+%Y-%m-%d_%T.%N').png\"<\/code> is the name of the image where the screenshot will be saved.<\/p>\n\n\n\n<p><strong>The beauty of the above date based command:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Times in nano-seconds (%N) make sure that two files created at the interval of even a nano second have different names so that they don&#8217;t overwrite each other.<\/li><li>Sorting based on times becomes easy.<\/li><\/ol>\n\n\n\n<p>To verify the beauty, you can just execute the given screenshot command couple of times in your terminal. Here is how the output files will look like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2021-12-20_23:13:10.639718047.png\n2021-12-20_23:13:13.580715441.png\n2021-12-20_23:13:18.507580139.png\n2021-12-20_23:13:20.517476383.png\n2021-12-20_23:13:23.277434727.png\n2021-12-20_23:13:36.722378523.png\n2021-12-20_23:13:38.646510476.png\n2021-12-20_23:13:41.255368267.png<\/code><\/pre>\n\n\n\n<p>Similarly, Linux system administrators can also create log files with unique names.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-2-example-2-creating-clock-for-tiling-window-managers\">2.2. Example 2: Creating Clock for Tiling Window Managers<\/h3>\n\n\n\n<p>Another <strong>example<\/strong> is what I use as my clock in my i3-tiling window manager:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date '+%d\/%m %I:%M %u'<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>14\/12 03:27 2<\/code><\/pre>\n\n\n\n<p>Notice how in the above example special characters like colon (<code>:<\/code>), slash (<code>\/<\/code>), and spaces are printed without any changes.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"696\" height=\"220\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Clock_in_i3bar_using_date_command.png?resize=696%2C220&#038;ssl=1\" alt=\"Clock in i3bar using date command\" class=\"wp-image-1444\"\/><figcaption><em>Figure: clock in i3-tiling window manager using the date command<\/em><\/figcaption><\/figure>\n\n\n\n<p>All of the above date commands were related to &#8216;current&#8217; time. What if we want to manipulate times other than the current one?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-how-to-print-a-given-time-instead-of-the-current-time-using-date-command-in-linux\">3. How to Print a Given Time Instead of the Current Time Using Date Command in Linux<\/h2>\n\n\n\n<p>This is done using the<strong> -d or &#8211;date <\/strong>flag. Here, the <a href=\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#2-using-touch-d\" target=\"_blank\" rel=\"noreferrer noopener\">date command&#8217;s <code>--date<\/code> flag is somewhat similar to the <code>--date<\/code> flag in the <strong>touch<\/strong> command<\/a>. <\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date --date=STRING<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date -d STRING<\/code><\/pre>\n\n\n\n<p>Here, date parses the STRING in human-readable form<strong>.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>-d STRING<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td><code>-d '14:02'<\/code><\/td><td>14:02 @ Today<\/td><\/tr><tr><td><code>-d 'yesterday'<\/code><\/td><td>current time @ yesterday<\/td><\/tr><tr><td><code>-d 'today'<\/code><\/td><td>current day<\/td><\/tr><tr><td><code>-d 'next sunday'<\/code><\/td><td>upcoming Sunday<\/td><\/tr><tr><td><code>-d 'tomorrow<\/code>&#8216;<\/td><td>current time but tomorrow<\/td><\/tr><tr><td><code>-d 'June 15, 2004'<\/code><\/td><td>June 15 2004 @ 12:00:00 AM<\/td><\/tr><tr><td><code>-d '@1619076682<\/code>&#8216;<\/td><td>Thu Apr 22 01:01:22 PM IST 2021; explained below<\/td><\/tr><tr><td><code>-d '00:03:00'<\/code><\/td><td>00:03:00 @ Today<\/td><\/tr><tr><td><code>-d '-1 hour'<\/code><\/td><td>1 hour ago<\/td><\/tr><tr><td><code>-d '+1 hour'<\/code><\/td><td>1 hour later<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>There are many such STRING formats given at <a href=\"https:\/\/www.gnu.org\/software\/coreutils\/date\">GNU documentation of date<\/a>. <\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date; date -d '1 year'<\/code><\/pre>\n\n\n\n<p>The above example contains two commands separated by a semicolon.<\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Tue Dec 14 05:58:02 AM IST 2021\nWed Dec 14 05:58:02 AM IST 2022<\/code><\/pre>\n\n\n\n<p> In the <strong>output,<\/strong> the first line is for the first date command and the second line is for the second date command. Notice the difference of 1 year:<\/p>\n\n\n\n<p>The<strong> -d<\/strong> flag can be used with +FORMAT to convert dates from one format into another. This is highly useful for Linux System Administrators where they very often need to analyze the log files.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-how-to-convert-dates-from-one-format-to-another-using-date-command-in-linux\">4. How to Convert Dates from One Format to Another Using Date Command in Linux<\/h2>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date -d STRING +FORMAT<\/code><\/pre>\n\n\n\n<p>One very good <strong>example<\/strong> will be the conversion of dates given in the \/var\/log\/pacman.log file in Archlinux into a more readable format:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date -d '2021-12-13T02:07:20+0530' '+%d\/%m\/%Y %I:%M %p %A'     <\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>13\/12\/2021 02:07 AM Monday<\/code><\/pre>\n\n\n\n<p>Another very important conversion is to\/from <strong>Unix Timestamp<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5-convert-unix-timestamp-to-date-and-vice-versa-using-date-command-in-linux\">5. Convert Unix Timestamp to Date and Vice-Versa Using Date Command in Linux<\/h2>\n\n\n\n<p>Before you begin, first you will need to know what is Unix Timestamp.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-1-unix-timestamp\">5.1. Unix Timestamp<\/h3>\n\n\n\n<p>It is a time elapsed since 00:00:00 UTC on 1 Jan 1970. 00:00:00 UTC on 1 Jan 1970 is called Unix Epoch.<\/p>\n\n\n\n<p>In order to find the <strong>current Unix Timestamp<\/strong>, you need to use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date '+%s'<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1639444603<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-2-date-to-unix-timestamp\">5.2. Date to Unix Timestamp<\/h3>\n\n\n\n<p>This is very simple. You just need to use <code>+%s<\/code> output format.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date -d '2021-04-22 04:39:00' '+%s'<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1639444957<\/code><\/pre>\n\n\n\n<p>Another fine example will be its usage with r<strong>tcwake <\/strong>command which wakes up the computer from the suspend mode at the given time:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo rtcwake --mode mem --time \"$(date -d \"30 minutes\" '+%s')\"<\/code><\/pre>\n\n\n\n<p>The above command suspends my computer immediately and it will wake it up 1 hour later. <\/p>\n\n\n\n<p>\ud83d\ude00 <strong>An energy-efficient alarm too<\/strong>l: I combine the above command with the <strong>ffplay<\/strong> command (included in the <strong>FFmpeg<\/strong> package) just before I take a short nap. It even suspends my PC and thus saving electricity. 30 minutes later my PC wakes up and then the alarm goes up. The overall command is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ sudo rtcwake --mode mem --time \"$(date -d \"30 minutes\" '+%s')\" ; ffplay ~\/Music\/alarm.mp3<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-3-unix-timestamp-to-date\">5.3. Unix Timestamp to Date<\/h3>\n\n\n\n<p>To convert Unix Timestamp to any other format, you need to prepend <code>@<\/code> with it in the -d flag.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date -d @UNIXTIMESTAMP +FORMAT<\/code><\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date -d '@1639444957' '+%d\/%m\/%Y %I:%M %p %A'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>14\/12\/2021 06:52 AM Tuesday<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6-how-to-get-last-modified-time-of-a-file-using-date-command-in-linux\">6. How to Get Last Modified Time of a File Using Date Command in Linux<\/h2>\n\n\n\n<p>For this, we use the &#8211;reference or -r flag.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date --reference=FILENAME<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date -r FILENAME<\/code><\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date --reference=\"\/etc\/lightdm\/lightdm.conf\"<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Wed Jul  8 12:28:15 AM IST 2020<\/code><\/pre>\n\n\n\n<p>\ud83d\ude03 <strong>Fun Fact: <\/strong>Linux treats directories, optical discs, CPUs, batteries, and everything else as files. So, you can also use a directory in place of FILENAME.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ date --reference=\"\/etc\"        \nTue Dec 14 01:27:33 AM IST 2021<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"7-how-to-get-times-in-different-time-zone-using-date-command-in-linux\">7. How to Get Times in Different Time Zone Using Date Command in Linux<\/h2>\n\n\n\n<p>All the above date commands can be prepended with <strong>TZ=TIME_ZONE<\/strong>. For <strong>example<\/strong>, to find the time in Paris, we can use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ TZ='Europe\/Paris' date<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Tue Dec 14 09:06:36 PM CET 2021<\/code><\/pre>\n\n\n\n<p>You might be wondering how can you find the TZ (<code>Europe\/Paris<\/code> in the above example). For that, use the<strong> tzselect<\/strong> command as I did in my case:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1765\" height=\"927\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Using_tzselect_to_find_time_zone.png?resize=1765%2C927&#038;ssl=1\" alt=\"Using tzselect to find time zone in Linux\" class=\"wp-image-1447\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Using_tzselect_to_find_time_zone.png?w=1765&amp;ssl=1 1765w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Using_tzselect_to_find_time_zone.png?resize=768%2C403&amp;ssl=1 768w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/Using_tzselect_to_find_time_zone.png?resize=1536%2C807&amp;ssl=1 1536w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption>Figure: Using tzselect to find time zone in Linux<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"8-conclusion\">8. Conclusion<\/h2>\n\n\n\n<p>There are many such practical examples. The key is constantly using the date command. To learn more, read <strong>info date, man date, and <a href=\"https:\/\/www.gnu.org\/software\/coreutils\/date\" target=\"_blank\" rel=\"noreferrer noopener\">GNU guide on date<\/a> <\/strong>documents.<\/p>\n\n\n\n<p>Thank you guys for staying up to this point. I have tried my best to cover everything without committing any mistakes. If you have any further questions, or there are some mistakes in the article, please notify me through the comment section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Everything about date command using practical examples &#8211; alarm clock, unique name generation, convert unix timestamp, different time zones.<\/p>\n","protected":false},"author":2,"featured_media":1470,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[17],"tags":[],"class_list":["post-1436","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line-tools"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Date Command in Linux\/Unix with Practical Examples | SmartTech101<\/title>\n<meta name=\"description\" content=\"Everything about date command using practical examples - alarm clock, unique name generation, convert unix timestamp, different time zones.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Date Command in Linux\/Unix with Practical Examples | SmartTech101\" \/>\n<meta property=\"og:description\" content=\"Everything about date command using practical examples - alarm clock, unique name generation, convert unix timestamp, different time zones.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"SmartTech101\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-15T18:30:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-11T20:42:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ajay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ajay_yadav\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/\"},\"author\":{\"name\":\"Ajay\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\"},\"headline\":\"Date Command in Linux\/Unix with Practical Examples\",\"datePublished\":\"2021-12-15T18:30:13+00:00\",\"dateModified\":\"2022-11-11T20:42:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/\"},\"wordCount\":1271,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png?fit=1280%2C720&ssl=1\",\"articleSection\":[\"Command Line Tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/\",\"url\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/\",\"name\":\"Date Command in Linux\/Unix with Practical Examples | SmartTech101\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png?fit=1280%2C720&ssl=1\",\"datePublished\":\"2021-12-15T18:30:13+00:00\",\"dateModified\":\"2022-11-11T20:42:32+00:00\",\"description\":\"Everything about date command using practical examples - alarm clock, unique name generation, convert unix timestamp, different time zones.\",\"breadcrumb\":{\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png?fit=1280%2C720&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png?fit=1280%2C720&ssl=1\",\"width\":1280,\"height\":720,\"caption\":\"Date Command in Linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/smarttech101.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Date Command in Linux\/Unix with Practical Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/smarttech101.com\/#website\",\"url\":\"https:\/\/smarttech101.com\/\",\"name\":\"SmartTech101\",\"description\":\"Do Everything in Linux\",\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/smarttech101.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\",\"name\":\"Ajay Yadav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"width\":180,\"height\":60,\"caption\":\"Ajay Yadav\"},\"logo\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\",\"name\":\"Ajay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"caption\":\"Ajay\"},\"sameAs\":[\"https:\/\/x.com\/ajay_yadav\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Date Command in Linux\/Unix with Practical Examples | SmartTech101","description":"Everything about date command using practical examples - alarm clock, unique name generation, convert unix timestamp, different time zones.","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:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/","og_locale":"en_US","og_type":"article","og_title":"Date Command in Linux\/Unix with Practical Examples | SmartTech101","og_description":"Everything about date command using practical examples - alarm clock, unique name generation, convert unix timestamp, different time zones.","og_url":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/","og_site_name":"SmartTech101","article_published_time":"2021-12-15T18:30:13+00:00","article_modified_time":"2022-11-11T20:42:32+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png","type":"image\/png"}],"author":"Ajay","twitter_card":"summary_large_image","twitter_creator":"@ajay_yadav","twitter_misc":{"Written by":"Ajay","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#article","isPartOf":{"@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/"},"author":{"name":"Ajay","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334"},"headline":"Date Command in Linux\/Unix with Practical Examples","datePublished":"2021-12-15T18:30:13+00:00","dateModified":"2022-11-11T20:42:32+00:00","mainEntityOfPage":{"@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/"},"wordCount":1271,"commentCount":0,"publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"image":{"@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png?fit=1280%2C720&ssl=1","articleSection":["Command Line Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/","url":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/","name":"Date Command in Linux\/Unix with Practical Examples | SmartTech101","isPartOf":{"@id":"https:\/\/smarttech101.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#primaryimage"},"image":{"@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png?fit=1280%2C720&ssl=1","datePublished":"2021-12-15T18:30:13+00:00","dateModified":"2022-11-11T20:42:32+00:00","description":"Everything about date command using practical examples - alarm clock, unique name generation, convert unix timestamp, different time zones.","breadcrumb":{"@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#primaryimage","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png?fit=1280%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png?fit=1280%2C720&ssl=1","width":1280,"height":720,"caption":"Date Command in Linux"},{"@type":"BreadcrumbList","@id":"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smarttech101.com\/"},{"@type":"ListItem","position":2,"name":"Date Command in Linux\/Unix with Practical Examples"}]},{"@type":"WebSite","@id":"https:\/\/smarttech101.com\/#website","url":"https:\/\/smarttech101.com\/","name":"SmartTech101","description":"Do Everything in Linux","publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smarttech101.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633","name":"Ajay Yadav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","width":180,"height":60,"caption":"Ajay Yadav"},"logo":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334","name":"Ajay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","caption":"Ajay"},"sameAs":["https:\/\/x.com\/ajay_yadav"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/12\/date_command_in_linux.png?fit=1280%2C720&ssl=1","_links":{"self":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1436"}],"collection":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/comments?post=1436"}],"version-history":[{"count":5,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1436\/revisions"}],"predecessor-version":[{"id":1734,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1436\/revisions\/1734"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media\/1470"}],"wp:attachment":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media?parent=1436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/categories?post=1436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/tags?post=1436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}