{"id":1951,"date":"2014-12-16T13:15:39","date_gmt":"2014-12-16T11:15:39","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=1951"},"modified":"2018-06-20T13:11:28","modified_gmt":"2018-06-20T10:11:28","slug":"javascript-date-format-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/","title":{"rendered":"Javascript Date Format Example"},"content":{"rendered":"<p>As different countries use different date format, the need to format them differently now has a solution in almost all programming languages and frameworks. Some of them use special functions, some others use dedicated libraries, and some just leave you to their syntax and your imagination.<\/p>\n<p>Let&#8217;s see what JavaScript provides for those of us in dire need to format dates.<\/p>\n<p>[ulp id=&#8217;tCIwOngQUb3zSUuF&#8217;]<\/p>\n<h2>Date objects<\/h2>\n<p><code>Date<\/code> objects are based on the number of milliseconds since January 1,1970 UTC. They have no syntax, but are stated using constructors, like below:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nnew Date(); \r\nnew Date(value); \r\nnew Date(dateString); \r\nnew Date(year, month&#x5B;, day&#x5B;, hour&#x5B;, minute&#x5B;, second&#x5B;, millisecond]]]]]);\r\n<\/pre>\n<p>You can use them like this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar today = new Date();\r\nvar birthday = new Date('November 16, 1994 01:00:00');\r\nvar birthday = new Date('1994-11-16T01:00:00');\r\nvar birthday = new Date(1994, 11, 16);\r\nvar birthday = new Date(1994, 11, 16, 1, 0, 0);\r\n<\/pre>\n<p>Be careful when invoking the <code>Date<\/code> object, because if you use it without the <code>new<\/code> operator, it will only return the current date and time as a string.<\/p>\n<p>The <code>Date<\/code> object has a number of specific qualities to it&#8217;s name, for example, if you give it an illogical value, say 3\/14\/2013, it transforms it into 3\/2\/2014. If you don&#8217;t provide a time and date, the constructor will fill it in with the systems time and date, and if two arguments are supplied, the other ones will be set to 0. JavaScript supports a number of universal formats, and even local equivalents of it, which provides consistency and uniform behavior across platforms.<\/p>\n<p><strong>Date.prototype<\/strong><br \/>\n<code>Date.prototype<\/code> allows you to add properties to the <code>Date<\/code> object. It is used together with the methods, which are divided into <em>getters<\/em>, <em>setters<\/em> and <em>conversion getters<\/em>, but we&#8217;ll discus them shortly. The properties inherited from the function are: <code>arity<\/code>, <code>caller<\/code>, <code>constructor<\/code>, <code>length<\/code> and <code>name<\/code>.<\/p>\n<h2>Methods<\/h2>\n<p>The three methods used with the <code>Date<\/code> object are <code>Date.now()<\/code>,<code>Date.parse()<\/code> and <code>Date.UTC()<\/code>.<\/p>\n<ul>\n<li><code>Date.now()<\/code> returns the current time of the system.<\/li>\n<li><code>Date.parse()<\/code> parses a string representation of a date and returns the numeric value corresponding it.<\/li>\n<li><code>Date.UTC()<\/code> returns the number of milliseconds since January 1,1970.<\/li>\n<\/ul>\n<p>Also there are these methods inherited from the function: <code>apply<\/code>, <code>call<\/code>, <code>toSource<\/code> and <code>toString<\/code>.<\/p>\n<h2>Date instances<\/h2>\n<p>The methods that <em>Date<\/em> instances inherit from <em>Date.prototype<\/em> can be divided into three big groups:<em>Getters<\/em>, <em>Setters<\/em> and <em>Conversion getters<\/em>.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong>Getters<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>We use <em>Getters<\/em> as <code>Date.prototype.getDay<\/code>, where you can put <code>Date<\/code>, <code>Month<\/code>, <code>Year<\/code>, <code>Milliseconds<\/code> and other ones which you can find <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Date#Getter\">here<\/a>, instead of <code>Day<\/code>.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong>Setters<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>We use <em>Setters<\/em> in a similar way: <code>Date.prototype.setMonth<\/code>. You can find the list on what exactly you can set, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Date#Setter\">here<\/a>.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong>Conversion getters<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>And finally, we use <em>Conversion getters<\/em> to get and convert dates at the same time. It is used like this: <code>Date.prototype.toISOString()<\/code>, and you can find a whole list on what you can convert <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Date#Conversion_getter\">here<\/a>.<\/p>\n<h2>Calculating elapsed time<\/h2>\n<p>By using <code>Date<\/code> objects you can calculate how much time has passed since you last did something, like this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar start = Date.now();\r\n\r\nrandomfunction();\r\nvar end = Date.now();\r\nvar elapsed = end - start; \r\n<\/pre>\n<p>You get the time in a specific moment, then do something for some time, and then get the time after you finish. You get the difference and that is the elapsed time in milliseconds.<\/p>\n<h2>JavaScript Libraries<\/h2>\n<p>There are lots of JavaScript libraries dedicated to data formatting. Two of the most efficient are <a href=\"http:\/\/www.datejs.com\/\">Datejs<\/a> and <a href=\"http:\/\/momentjs.com\/\">Moment.js<\/a>, both open source and released under the MIT license. We&#8217;ll see how they work.<\/p>\n<p><strong>Datejs<\/strong><br \/>\nYou can download Datejs <a href=\"https:\/\/code.google.com\/p\/datejs\/downloads\/list\">here<\/a>, and then script it in you main file. It gives you the possibility to format you dates according to where you live, giving you more than 150 options. To do that you just swap the <code>date.js<\/code> file for a culture specific one, like below:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;!--Swap this file for the one you need, example for german and french below--&gt;\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;date.js&quot;&gt;&lt;\/script&gt;\r\n\r\n&lt;!-- German--&gt;\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;date-de-DE.js&quot;&gt;&lt;\/script&gt;\r\n\r\n&lt;!-- French --&gt;\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;date-fr-FR.js&quot;&gt;&lt;\/script&gt;\r\n<\/pre>\n<p>Let&#8217;s get our hands on it. Want to know what&#8217;s the date today? Write this code:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nDate.today();\r\n<\/pre>\n<p>Or what will be the day ten days from now?<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nDate.today().add(10).days();\r\n<\/pre>\n<p>If you wanna know what the date will be this Friday, you write this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nDate.friday();\r\n<\/pre>\n<p>You can even ask if Friday is today, doing this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nDate.today().is().friday();\r\n<\/pre>\n<p>And in case it returns false (it can even return true), you can ask what day it is like so:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nDate.today().getDayName();\r\n<\/pre>\n<p>You can even get the first Monday or last Sunday of the year by writing this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nDate.january().first().monday();\r\n\r\nDate.dec().final().sunday();\r\n<\/pre>\n<p>Included with the Date.js library is a really good replacement for JavaScript Date parse. Take a look at the code:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nDate.parse('today');\r\n\r\nDate.parse('tomorrow');\r\n\r\nDate.parse('July 8');\r\n\r\nDate.parse('July 8th, 2007');\r\n\r\nDate.parse('July 8th, 2007, 10:30 PM');\r\n<\/pre>\n<p>We have parsed the date of today, tomorrow, July 8th, July 8th of 2007 and July 8th of 2007 at 10:30 PM, just by using the <code>Date.parse();<\/code> function.<\/p>\n<p><strong>Moment.js<\/strong><\/p>\n<p>Moment.js is created to parse, validate, manipulate and display dates in JavaScript. It is designed to work both in the browser and Node.js. You can install it through Bower, npm or NuGet.You can format dates like this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nmoment().format('MMMM Do YYYY, h:mm:ss a'); \/\/ December 7th 2014, 6:17:51 pm\r\nmoment().format('dddd');                    \/\/ Sunday\r\nmoment().format(&quot;MMM Do YY&quot;);               \/\/ Dec 7th 14\r\nmoment().format('YYYY &#x5B;escaped] YYYY');     \/\/ 2014 escaped 2014                     \r\nmoment().format();                          \/\/ 2014-12-07T18:18:11+01:00\r\n<\/pre>\n<p>You can get a relative time, like this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nmoment(&quot;20111031&quot;, &quot;YYYYMMDD&quot;).fromNow(); \/\/ 3 years ago\r\nmoment(&quot;20120620&quot;, &quot;YYYYMMDD&quot;).fromNow(); \/\/ 2 years ago\r\nmoment().startOf('day').fromNow();        \/\/ 18 hours ago\r\nmoment().endOf('day').fromNow();          \/\/ in 6 hours\r\nmoment().startOf('hour').fromNow();      \/\/20 minutes ago\r\n<\/pre>\n<p>And it even provides you multiple locale support:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nmoment().format('L');    \/\/ 07\/12\/2014\r\nmoment().format('l');    \/\/ 7\/12\/2014\r\nmoment().format('LL');   \/\/ 7 Dhjetor 2014\r\nmoment().format('ll');   \/\/ 7 Dhj 2014\r\nmoment().format('LLL');  \/\/ 7 Dhjetor 2014 18:21\r\nmoment().format('lll');  \/\/ 7 Dhj 2014 18:21\r\nmoment().format('LLLL'); \/\/ E Diel, 7 Dhjetor 2014 18:21\r\nmoment().format('llll'); \/\/ Die, 7 Dhj 2014 18:22\r\n<\/pre>\n<p><strong>Later.js<\/strong><br \/>\n<a href=\"http:\/\/bunkat.github.io\/later\/\">Later.js<\/a> is a library that triggers recurring events, and defines complex schedules. It can even use user-friendly expressions such as &#8220;every 10 seconds&#8221;. You can install it through npm:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ npm install later\r\n<\/pre>\n<p>Or even using Bower:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ bower install later\r\n<\/pre>\n<p>You can define a schedule by text, recursion or manually like below:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar textSched = later.parse.text('at 10:15am every weekday');\r\nvar recurSched = later.parse.recur().last().dayOfMonth();\r\nvar manualSched = {schedules: &#x5B;{M: 3, D: 21}]};\r\n<\/pre>\n<p>Still you can define more complex schedules like this one, who fires the weekday closest to the 15th of every month except March. Here&#8217;s the code:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar complexSched = later.parse.recur()\r\n                  .on(15).dayOfMonth().onWeekday().on(2).hour()\r\n                .and()\r\n                  .on(14).dayOfMonth().on(6).dayOfWeek().on(2).hour()\r\n                .and()\r\n                  .on(16).dayOfMonth().on(2).dayOfWeek().on(2).hour()\r\n                .except()\r\n                  .on(3).month();\r\n<\/pre>\n<p>You can even configure your timezone, either in UTC format or in local time. You configure it in UTC like this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nlater.date.UTC();\r\n<\/pre>\n<p>And you can turn it to local time like this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nlater.date.localTime();\r\n<\/pre>\n<p>With Library.js you can even calculate future or past occurrences once you set a recurring schedule. Look at the code snippet below:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar recurSched = later.parse.recur().last().dayOfMonth();\r\n      next = later.schedule(recurSched).next(10);\r\n<\/pre>\n<p>Also a lot of other functions of this library are available, and you can take a look at it&#8217;s documentation on Github or even modify it yourself as it&#8217;s open-source.<\/p>\n<h2>Download the source code<\/h2>\n<p>This was an example of JavaScript date format.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here : <strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/12\/DateFormat.zip\">DateFormat<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>As different countries use different date format, the need to format them differently now has a solution in almost all programming languages and frameworks. Some of them use special functions, some others use dedicated libraries, and some just leave you to their syntax and your imagination. Let&#8217;s see what JavaScript provides for those of us &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-1951","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 Date Format Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn more about javascript date format? Check out our Example where we use special functions, dedicated libraries for different date formats!\" \/>\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-date-format-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Javascript Date Format Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about javascript date format? Check out our Example where we use special functions, dedicated libraries for different date formats!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-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=\"2014-12-16T11:15:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-20T10:11:28+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=\"7 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-date-format-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/\"},\"author\":{\"name\":\"Era Balliu\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e\"},\"headline\":\"Javascript Date Format Example\",\"datePublished\":\"2014-12-16T11:15:39+00:00\",\"dateModified\":\"2018-06-20T10:11:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/\"},\"wordCount\":1296,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-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-date-format-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/\",\"name\":\"Javascript Date Format Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"datePublished\":\"2014-12-16T11:15:39+00:00\",\"dateModified\":\"2018-06-20T10:11:28+00:00\",\"description\":\"Interested to learn more about javascript date format? Check out our Example where we use special functions, dedicated libraries for different date formats!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-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-date-format-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 Date Format 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 Date Format Example - Web Code Geeks - 2026","description":"Interested to learn more about javascript date format? Check out our Example where we use special functions, dedicated libraries for different date formats!","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-date-format-example\/","og_locale":"en_US","og_type":"article","og_title":"Javascript Date Format Example - Web Code Geeks - 2026","og_description":"Interested to learn more about javascript date format? Check out our Example where we use special functions, dedicated libraries for different date formats!","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-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":"2014-12-16T11:15:39+00:00","article_modified_time":"2018-06-20T10:11:28+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":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/"},"author":{"name":"Era Balliu","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e"},"headline":"Javascript Date Format Example","datePublished":"2014-12-16T11:15:39+00:00","dateModified":"2018-06-20T10:11:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/"},"wordCount":1296,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-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-date-format-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/","name":"Javascript Date Format Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","datePublished":"2014-12-16T11:15:39+00:00","dateModified":"2018-06-20T10:11:28+00:00","description":"Interested to learn more about javascript date format? Check out our Example where we use special functions, dedicated libraries for different date formats!","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-date-format-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-date-format-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 Date Format 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\/1951","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=1951"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/1951\/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=1951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=1951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=1951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}