{"id":10576,"date":"2016-02-03T16:15:14","date_gmt":"2016-02-03T14:15:14","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=10576"},"modified":"2018-01-10T16:15:29","modified_gmt":"2018-01-10T14:15:29","slug":"javascript-calendar-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/","title":{"rendered":"Javascript Calendar Example"},"content":{"rendered":"<p>Calendars are a very useful widget or part of an application, as we can see from the frequency in which we use them ourselves (at least for the forgetful people like me!). In fact they can be so useful that there are currently apps dedicated solely to this function in our smartphones and other gadgets. How can we create one ourselves using Javascript? Let&#8217;s see below!<\/p>\n<h2>1. Things to consider before creating a calendar<\/h2>\n<p>We decided to work on creating our own Javascript Calendar. But where exactly do we start? Let&#8217;s see!<\/p>\n<p>What we need is a calendar that displays correctly the number of days in a month and also the weekday to which it corresponds, so the best view we could give it is the regular table, the classic one. For that we would need a piece of code that would do the correct rendering and presenting of our code. <\/p>\n<p>Moreover we would need a correct Javascript function that displays the correct number of days for a month (remember that February is a leap year!), the correct weekday for it and also for the first day of the month. <\/p>\n<p>Lastly, we would want our calendar to be presentable, since that is crucial to the accurate understanding of it. To fulfill all these requirements, we will divide our code into three parts: the HTML, the CSS and most importantly the Javascript. Let&#8217;s get to it!<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;tCIwOngQUb3zSUuF&#8217;]<\/p>\n<h2>2. The HTML Part<\/h2>\n<p>Firstly, we have to create an HTML document that will be the base of the calendar we&#8217;re building. As you can see in the code below, it will be very basic, containing only a <code>div<\/code> element with the id <code>calendar<\/code>, which we will be using later in other parts of our code. Take a look at the code below:<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.html<\/em><\/span><\/p>\n<pre class=\"brush:xml\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;JavaScript calendar&lt;\/title&gt;\r\n\r\n    &lt;script src=\"calendar.js\"&gt;&lt;\/script&gt;\r\n    &lt;link href=\"calendar.css\" rel=\"stylesheet\"\/&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body onload=\"displayCalendar()\"&gt;\r\n\r\n    &lt;div id=\"calendar\"&gt;&lt;\/div&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>The only additions to the code that we didn&#8217;t already mention are the linking and scripting of the Javascript and CSS part of our code, as we decided to put them into separate files to make our code more easily understandable and less clustered, and also the function <code>displayCalendar()<\/code> which we have put inside the <code>body<\/code> tag. This way, whenever our document is loaded, through the <code>onload<\/code> event, the function will be executed immediately and we will have our calendar displayed nicely in it. However, the HTML part is just this small thing. Impressive, right?<\/p>\n<h2>3. The Javascript Part<\/h2>\n<p>Admittedly, Javascript is the most important part in making an accurate and dynamic calendar. That doesn&#8217;t mean that it is an especially difficult part, though. Before we get to the code, we have to mention that we will base our work largely on a built in Javascript object, that is the <code>Date<\/code> object. <\/p>\n<h3>3.1 Global Variables<\/h3>\n<p>This object parses a given date and gives us useful information about that date. If we leave the argument unspecified, it will accept the current date as one by default. However, the <code>Date<\/code> object has it&#8217;s limitations, some of them being that it doesn&#8217;t know the names of the months or days of the week, the lengths of the months (and consequently the leap year limitations), or the day of the week in which the month starts.<\/p>\n<p>These &#8220;flaws&#8221; of the <code>Date<\/code> object will be compensated by the global variables that we will be using in our code. Let&#8217;s take a look at the code part by part. <\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\r\n    var htmlContent =\"\";\r\n    var FebNumberOfDays =\"\";\r\n    var counter = 1;\r\n<\/pre>\n<p>We will have a number of global variables during the course of our code, but the ones above are the first ones, and they are used as simple helpers. The first one, <code>htmlContent<\/code> is used for the HTML content we will generate later on, while <code>FebNumberOfDays<\/code> is used to store the number of days that the second month of the year, February, is going to last. We need only the length of this month as a variable as it is the only one that changes from one year to the other. Next up is a counter that will help us later on. Now that we&#8217;re done with this, take a look at the code snippet below:<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\r\n    var dateNow = new Date();\r\n    var month = dateNow.getMonth();\r\n    var day = dateNow.getDate();\r\n    var year = dateNow.getFullYear();\r\n<\/pre>\n<h3>3.2 Fixing the shortcomings of built-in features<\/h3>\n<p>As you see, here we have used the <code>Date<\/code> object to get the current date and also relevant information about it such as the month, day and year to which it corresponds. Below you will find a code snippet that specifies the previous and next month, which will be useful later in order to determine the right weekday in which the month starts.<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\r\n    var nextMonth = month+1; \r\n    var prevMonth = month-1;\r\n<\/pre>\n<p>Now let&#8217;s determine the number of days in February with the function shown below, which is also one of the easiest and most popular solutions online about this problem:<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\r\n   if (month == 1){\r\n        if ( (year%100!=0) &amp;&amp; (year%4==0) || (year%400==0)){\r\n            FebNumberOfDays = 29;\r\n        }else{\r\n            FebNumberOfDays = 28;\r\n        }\r\n    }\r\n<\/pre>\n<p>When we explained the <code>Date<\/code> object, we mentioned that it had a few shortcomings that we would have to compensate for later. You might remember that some of them had to do with the labels for months and weekdays, and the lengths of each month. The code snippet below would solve these problems:<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\r\n    var monthNames = [\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\", \"December\"];\r\n    var dayNames = [\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thrusday\",\"Friday\", \"Saturday\"];\r\n    var dayPerMonth = [\"31\", \"\"+FebNumberOfDays+\"\",\"31\",\"30\",\"31\",\"30\",\"31\",\"31\",\"30\",\"31\",\"30\",\"31\"];\r\n<\/pre>\n<p>With the next part of code, we determine the days of the previous and next months and also the days of the week. The code would go like this:<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\r\n    var nextDate = new Date(nextMonth +' 1 ,'+year);\r\n    var weekdays= nextDate.getDay();\r\n    var weekdays2 = weekdays;\r\n    var numOfDays = dayPerMonth[month];\r\n<\/pre>\n<h3>3.3 Displaying the Calendar<\/h3>\n<p>The loop shown in the code snippet below will make it possible for your calendar to have white spaces in the dates of the previous month:<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\r\n    while (weekdays&gt;0){\r\n        htmlContent += \"&lt;td class='monthPre'&gt;&lt;\/td&gt;\";\r\n\r\n        weekdays--;\r\n    }\r\n<\/pre>\n<p>We wrote all the code for the logic behind our Calendar. What is left now is only building our calendar&#8217;s body using HTML. We will do that by using the code snippet below:<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\r\nwhile (counter &lt;= numOfDays){\r\n\r\n        \r\n        if (weekdays2 &gt; 6){\r\n            weekdays2 = 0;\r\n            htmlContent += \"&lt;\/tr&gt;&lt;tr&gt;\";\r\n        }\r\n\r\n\r\n\r\n        if (counter == day){\r\n            htmlContent +=\"&lt;td class='dayNow'  onMouseOver='this.style.background=\\\"#FFFF00\\\"; this.style.color=\\\"#FFFFFF\\\"' \"+\r\n                \"onMouseOut='this.style.background=\\\"#FFFFFF\\\"; this.style.color=\\\"#00FF00\\\"'&gt;\"+counter+\"&lt;\/td&gt;\";\r\n        }else{\r\n            htmlContent +=\"&lt;td class='monthNow' onMouseOver='this.style.background=\\\"#FFFF00\\\"'\"+\r\n                \" onMouseOut='this.style.background=\\\"#FFFFFF\\\"'&gt;\"+counter+\"&lt;\/td&gt;\";\r\n\r\n        }\r\n\r\n        weekdays2++;\r\n        counter++;\r\n    }  \r\n<\/pre>\n<p>Inside the while cycle you will see that the first conditional clause is the one that is used to determine when we will have a new line, while the rest of the code highlights the current date. <\/p>\n<p>Let&#8217;s top it all off by creating the HTML body of the calendar using the code below:<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\r\nvar calendarBody = \"&lt;table class='calendar'&gt; &lt;tr class='monthNow'&gt;&lt;th colspan='7'&gt;\"\r\n        +monthNames[month]+\" \"+ year +\"&lt;\/th&gt;&lt;\/tr&gt;\";\r\n    calendarBody +=\"&lt;tr class='dayNames'&gt;  &lt;td&gt;Sun&lt;\/td&gt;  &lt;td&gt;Mon&lt;\/td&gt; &lt;td&gt;Tues&lt;\/td&gt;\"+\r\n        \"&lt;td&gt;Wed&lt;\/td&gt; &lt;td&gt;Thurs&lt;\/td&gt; &lt;td&gt;Fri&lt;\/td&gt; &lt;td&gt;Sat&lt;\/td&gt; &lt;\/tr&gt;\";\r\n    calendarBody += \"&lt;tr&gt;\";\r\n    calendarBody += htmlContent;\r\n    calendarBody += \"&lt;\/tr&gt;&lt;\/table&gt;\";\r\n    document.getElementById(\"calendar\").innerHTML=calendarBody;\r\n<\/pre>\n<p>All this code will be placed inside a function that we named <code>displayCalendar<\/code>, if you&#8217;ll remember it&#8217;s name from the HTML part in the first part of the article. With this, we&#8217;re done.<\/p>\n<h2>4. The CSS Part<\/h2>\n<p>Even though we are finished with the most part of our calendar, we have to put in a few touches of CSS lest it look completely and utterly ugly and difficult to understand too, for that matter. This is why, being the passionate people we are about style, we use the code snippet below to make our calendar look more presentable:<\/p>\n<p><span style=\"text-decoration: underline\"><em>calendar.css<\/em><\/span><\/p>\n<pre class=\"brush:css\">\r\n.monthPre{\r\n    color: gray;\r\n    text-align: center;\r\n}\r\n.monthNow{\r\n    color: blue;\r\n    text-align: center;\r\n}\r\n.dayNow{\r\n    border: 2px solid black;\r\n    color: #FF0;\r\n    text-align: center;\r\n}\r\n.calendar td{\r\n    htmlContent: 2px;\r\n    width: 40px;\r\n}\r\n.monthNow th{\r\n    background-color: #000000;\r\n    color: #FFFFFF;\r\n    text-align: center;\r\n}\r\n.dayNames{\r\n    background: #0FF000;\r\n    color: #FFFFFF;\r\n    text-align: center;\r\n}\r\n<\/pre>\n<p>The calendar we built will look like below:<\/p>\n<figure id=\"attachment_10646\" aria-describedby=\"caption-attachment-10646\" style=\"width: 762px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/Capture.jpg\" rel=\"attachment wp-att-10646\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/Capture.jpg\" alt=\"Calendar\" width=\"762\" height=\"423\" class=\"size-full wp-image-10646\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/Capture.jpg 762w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/Capture-300x167.jpg 300w\" sizes=\"(max-width: 762px) 100vw, 762px\" \/><\/a><figcaption id=\"caption-attachment-10646\" class=\"wp-caption-text\">Calendar<\/figcaption><\/figure>\n<p>And with this, you now have you calendar, accurate and pretty. However, don&#8217;t refrain from experimenting by yourself!<\/p>\n<h2>5. Download the source code<\/h2>\n<p>This was an example of Calendars in Javascript.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/calendar.zip\">calendar<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Calendars are a very useful widget or part of an application, as we can see from the frequency in which we use them ourselves (at least for the forgetful people like me!). In fact they can be so useful that there are currently apps dedicated solely to this function in our smartphones and other gadgets. &hellip;<\/p>\n","protected":false},"author":25,"featured_media":920,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-10576","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Javascript Calendar Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Calendars are a very useful widget or part of an application, as we can see from the frequency in which we use them ourselves (at least for the forgetful\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Javascript Calendar Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Calendars are a very useful widget or part of an application, as we can see from the frequency in which we use them ourselves (at least for the forgetful\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/era.balliu.7\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-03T14:15:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-10T14:15:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Era Balliu\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@BalliuEra\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Era Balliu\" \/>\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:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/\"},\"author\":{\"name\":\"Era Balliu\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e\"},\"headline\":\"Javascript Calendar Example\",\"datePublished\":\"2016-02-03T14:15:14+00:00\",\"dateModified\":\"2018-01-10T14:15:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/\"},\"wordCount\":1159,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/\",\"name\":\"Javascript Calendar Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"datePublished\":\"2016-02-03T14:15:14+00:00\",\"dateModified\":\"2018-01-10T14:15:29+00:00\",\"description\":\"Calendars are a very useful widget or part of an application, as we can see from the frequency in which we use them ourselves (at least for the forgetful\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Javascript Calendar Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e\",\"name\":\"Era Balliu\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f6adddf7eada210f682608fea9d8159441369ec622998a5851a447e0a2bfa3f3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f6adddf7eada210f682608fea9d8159441369ec622998a5851a447e0a2bfa3f3?s=96&d=mm&r=g\",\"caption\":\"Era Balliu\"},\"description\":\"Era is a Telecommunications Engineering student, with a great passion for new technologies. Up until now she has been coding with HTML\/CSS, Bootstrap and other front-end coding languages and frameworks, and her recent love is Angular JS.\",\"sameAs\":[\"http:\/\/www.webcodegeeks.com\/\",\"https:\/\/www.facebook.com\/era.balliu.7\",\"https:\/\/www.instagram.com\/eraballiu\/\",\"https:\/\/www.linkedin.com\/in\/eraballiu\",\"https:\/\/www.pinterest.com\/001r2gw0jt0ln6d\/\",\"https:\/\/x.com\/BalliuEra\",\"https:\/\/www.youtube.com\/c\/eraballiu\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/era-balliu\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Javascript Calendar Example - Web Code Geeks - 2026","description":"Calendars are a very useful widget or part of an application, as we can see from the frequency in which we use them ourselves (at least for the forgetful","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:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/","og_locale":"en_US","og_type":"article","og_title":"Javascript Calendar Example - Web Code Geeks - 2026","og_description":"Calendars are a very useful widget or part of an application, as we can see from the frequency in which we use them ourselves (at least for the forgetful","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/era.balliu.7","article_published_time":"2016-02-03T14:15:14+00:00","article_modified_time":"2018-01-10T14:15:29+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","type":"image\/jpeg"}],"author":"Era Balliu","twitter_card":"summary_large_image","twitter_creator":"@BalliuEra","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Era Balliu","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/"},"author":{"name":"Era Balliu","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e"},"headline":"Javascript Calendar Example","datePublished":"2016-02-03T14:15:14+00:00","dateModified":"2018-01-10T14:15:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/"},"wordCount":1159,"commentCount":5,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/","name":"Javascript Calendar Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","datePublished":"2016-02-03T14:15:14+00:00","dateModified":"2018-01-10T14:15:29+00:00","description":"Calendars are a very useful widget or part of an application, as we can see from the frequency in which we use them ourselves (at least for the forgetful","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-calendar-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Javascript Calendar Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e","name":"Era Balliu","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f6adddf7eada210f682608fea9d8159441369ec622998a5851a447e0a2bfa3f3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f6adddf7eada210f682608fea9d8159441369ec622998a5851a447e0a2bfa3f3?s=96&d=mm&r=g","caption":"Era Balliu"},"description":"Era is a Telecommunications Engineering student, with a great passion for new technologies. Up until now she has been coding with HTML\/CSS, Bootstrap and other front-end coding languages and frameworks, and her recent love is Angular JS.","sameAs":["http:\/\/www.webcodegeeks.com\/","https:\/\/www.facebook.com\/era.balliu.7","https:\/\/www.instagram.com\/eraballiu\/","https:\/\/www.linkedin.com\/in\/eraballiu","https:\/\/www.pinterest.com\/001r2gw0jt0ln6d\/","https:\/\/x.com\/BalliuEra","https:\/\/www.youtube.com\/c\/eraballiu"],"url":"https:\/\/www.webcodegeeks.com\/author\/era-balliu\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/10576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=10576"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/10576\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=10576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=10576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=10576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}