{"id":18494,"date":"2013-07-12T17:34:00","date_gmt":"2013-07-12T15:34:00","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=18494"},"modified":"2013-07-12T17:34:00","modified_gmt":"2013-07-12T15:34:00","slug":"javascript-date-utc-with-a-month-off-by-one","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2013\/07\/12\/javascript-date-utc-with-a-month-off-by-one\/","title":{"rendered":"JavaScript Date.UTC() with a month off by one"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>It&#8217;s like they say &#8211; there are two difficult things in Computer Science: naming things, invaliding cache, and off-by-one errors. \u00a0Today I came across a weird issue with JavaScript&#8217;s <em>Date.UTC()<\/em> shifting the month by one. \u00a0The day and year were fine, but the month was off by one. \u00a0Interesting, considering that the date was parsed from a standard MySQL date (like 2013-07-12). \u00a0 Well, another thing they say: when all else fails, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Date\/UTC\">read the manual<\/a>. \u00a0And that&#8217;s where the solution is:<\/p>\n<blockquote><p><strong>Parameters<\/strong><\/p>\n<ul>\n<li><strong>year<\/strong>: A year after 1900.<\/li>\n<li><strong>month<\/strong>: An integer between 0 and 11 representing the month.<\/li>\n<li><strong>date<\/strong>: An integer between 1 and 31 representing the day of the month.<\/li>\n<\/ul>\n<\/blockquote>\n<p>Fun.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>It&#8217;s like they say &#8211; there are two difficult things in Computer Science: naming things, invaliding cache, and off-by-one errors. \u00a0Today I came across a weird issue with JavaScript&#8217;s Date.UTC() shifting the month by one. \u00a0The day and year were fine, but the month was off by one. \u00a0Interesting, considering that the date was parsed &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2013\/07\/12\/javascript-date-utc-with-a-month-off-by-one\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">JavaScript Date.UTC() with a month off by one<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62,1334],"tags":[1139],"keyring_services":[],"class_list":["post-18494","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","category-web-work","tag-javascript"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":15674,"url":"https:\/\/mamchenkov.net\/wordpress\/2011\/10\/06\/ubuntu-naming-permutations\/","url_meta":{"origin":18494,"position":0},"title":"Ubuntu naming permutations","author":"Leonid Mamchenkov","date":"October 6, 2011","format":false,"excerpt":"Even though I don't use Ubuntu myself, I think nothing stops me from sharing the fun those guys have these days. \u00a0But first, if you are anything like me, you need a little bit of context. \u00a0Here is a wiki page that explains Ubuntu code names and lists some of\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":42426,"url":"https:\/\/mamchenkov.net\/wordpress\/2019\/04\/09\/chrome-extensions-php-console-and-javascript-errors-notifier\/","url_meta":{"origin":18494,"position":1},"title":"Chrome Extensions: PHP Console and JavaScript Errors Notifier","author":"Leonid Mamchenkov","date":"April 9, 2019","format":false,"excerpt":"Here are a couple of handy Google Chrome extensions that I came across the other day. PHP Console PHP Console can display PHP errors and var dumps in the Google Chrome Developer Console and notification popups. It can also execute PHP code remotely, with the help of this server side\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/04\/javascript-error-notifier.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/04\/javascript-error-notifier.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/04\/javascript-error-notifier.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":28370,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/02\/10\/top-10-javascript-errors\/","url_meta":{"origin":18494,"position":2},"title":"Top 10 JavaScript errors","author":"Leonid Mamchenkov","date":"February 10, 2018","format":false,"excerpt":"Here's the list of \"Top 10 JavaScript errors from 1000+ projects (and how to avoid them)\".\u00a0 The list is not surprising at all, but still serves as a good reminder on how write better code in JavaScript.","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/02\/javascript-error-graph-500x310.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":28618,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/06\/10\/capture-and-report-javascript-errors-with-window-onerror\/","url_meta":{"origin":18494,"position":3},"title":"Capture and Report JavaScript Errors with window.onerror","author":"Leonid Mamchenkov","date":"June 10, 2018","format":false,"excerpt":"\"Capture and Report JavaScript Errors with window.onerror\" tutorial shows an easy way to capture, log and troubleshoot client-side errors: onerror\u00a0is a special browser event that fires whenever an uncaught\u00a0JavaScript errorhas been thrown. It's one of the easiest ways to log client-side errors and report them to your servers. It's also\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28279,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/12\/15\/replaying-javascript-errors-from-the-userland\/","url_meta":{"origin":18494,"position":4},"title":"Replaying JavaScript errors from the userland","author":"Leonid Mamchenkov","date":"December 15, 2017","format":false,"excerpt":"I came across this interesting dive into monitoring, troubleshooting, and replaying JavaScript errors from the userland - \"A user encounters a JavaScript error. You\u2019ll never guess what happens next!!\". This is not something immediately applicable for my projects at work, but gives me a lot to think about.","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/12\/error-journey-500x340.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":22193,"url":"https:\/\/mamchenkov.net\/wordpress\/2014\/07\/15\/peg-js-parser-generator-for-javascript\/","url_meta":{"origin":18494,"position":5},"title":"PEG.js &#8211; Parser Generator for JavaScript","author":"Leonid Mamchenkov","date":"July 15, 2014","format":"link","excerpt":"PEG.js - Parser Generator for JavaScript. PEG.js is a simple parser generator for JavaScript that produces fast parsers with excellent error reporting. You can use it to process complex data or computer languages and build transformers, interpreters, compilers and other tools easily.","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/18494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=18494"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/18494\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=18494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=18494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=18494"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=18494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}