{"id":33836,"date":"2021-10-06T17:01:10","date_gmt":"2021-10-06T21:01:10","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=33836"},"modified":"2021-10-08T16:58:35","modified_gmt":"2021-10-08T20:58:35","slug":"date-d-vs-date-s","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2021\/10\/06\/date-d-vs-date-s\/","title":{"rendered":"&ldquo;date -d&rdquo; vs. &ldquo;date -s&rdquo;"},"content":{"rendered":"<p><a href=\"https:\/\/rachelbythebay.com\/w\/2021\/10\/05\/cmd\/\">Rachel Kroll<\/a>:<\/p>\n<blockquote cite=\"https:\/\/rachelbythebay.com\/w\/2021\/10\/05\/cmd\/\"><pre>$ date -d @1700000000\nTue Nov 14 14:13:20 PST 2023\n<\/pre><p>The problem is, there&rsquo;s another command very much like it that will even \nspit out the same output, only it has a nice little side-effect: <em>it \nalso sets the clock<\/em>.  That command is date <code>-s<\/code>.\n<\/p><p>\nIf you&rsquo;re on a QWERTY layout or are generally familiar with it, you \nmight notice that [S] and [D] are right next to each other and are an \neasy typo to make with your left hand.  That&rsquo;s one way to screw up.\n<\/p><p>\nAnother problem is that you might not have known that -s has that \neffect[&#8230;]\n<\/p><\/blockquote>\n<p>There doesn&rsquo;t seem to be a <code>-s<\/code> in the Mac version of <code>date<\/code>.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/10\/05\/facebook-bgp-outage\/\">Facebook BGP Outage<\/a><\/li>\n<\/ul>\n\n<p id=\"date-d-vs-date-s-update-2021-10-08\">Update (2021-10-08): <a href=\"https:\/\/twitter.com\/matt_garber\/status\/1445860155506118664\">Matt Garber<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/matt_garber\/status\/1445860155506118664\">\n<p>That&rsquo;s one of several differences between the GNU coreutils <code>date<\/code> on Linux, and the BSD version included in at least FreeBSD and macOS. Also, the BSD version&rsquo;s <code>-d<\/code> flag is completely different: &ldquo;Set the kernel&rsquo;s value for daylight saving time&rdquo;.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/simonboots\/status\/1446003702569992193\">Simon Stiefel<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/simonboots\/status\/1446003702569992193\">\n<p>On macOS, no option is needed to change the flag which is arguably worse, e.g. <code>date 1234<\/code> sets the time.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/cdzombak\/status\/1445896267171708932\">Chris Dzombak<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/cdzombak\/status\/1445896267171708932\">\n<p><a href=\"https:\/\/dzombak.com\/blog\/2021\/10\/Small-commands-big-consequences.html\">also<\/a>, crontab -e vs. crontab -r<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Rachel Kroll: $ date -d @1700000000 Tue Nov 14 14:13:20 PST 2023 The problem is, there&rsquo;s another command very much like it that will even spit out the same output, only it has a nice little side-effect: it also sets the clock. That command is date -s. If you&rsquo;re on a QWERTY layout or are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2021-10-06T21:01:14Z","apple_news_api_id":"72d6b827-cf19-4745-8c60-39715005ef70","apple_news_api_modified_at":"2021-10-08T20:58:39Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/Acta4J88ZR0WMYDlxUAXvcA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[30,1891,364,163],"class_list":["post-33836","post","type-post","status-publish","format-standard","hentry","category-technology","tag-mac","tag-macos-11-0","tag-time","tag-unix"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/33836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=33836"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/33836\/revisions"}],"predecessor-version":[{"id":33873,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/33836\/revisions\/33873"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=33836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=33836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=33836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}