{"id":114,"date":"2024-11-11T04:54:23","date_gmt":"2024-11-11T04:54:23","guid":{"rendered":"https:\/\/techkubo.com\/javascript\/?p=114"},"modified":"2025-05-17T03:45:39","modified_gmt":"2025-05-17T03:45:39","slug":"javascript-data-and-time","status":"publish","type":"post","link":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/","title":{"rendered":"JavaScript Date and Time"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Creating a Date Object<\/strong><\/h2>\n\n\n\n<p>The <code>Date<\/code> object is used to work with dates and times. You can create a new <code>Date<\/code> object using the <code>Date<\/code> constructor.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Explanation of Code:<\/strong><\/p>\n\n\n\n<p>This example creates a <code>Date<\/code> object representing the current date and time.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">let currentDate = new Date();\nconsole.log(currentDate);  \/\/ Output: Current date and time<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Getting Date and Time Values<\/strong><\/h2>\n\n\n\n<p>This example demonstrates how to get various parts of the date and time using methods like <code>getFullYear()<\/code>, <code>getMonth()<\/code>, <code>getDate()<\/code>, <code>getHours()<\/code>, <code>getMinutes()<\/code>, <code>getSeconds()<\/code>, <code>getMilliseconds()<\/code>, and <code>getDay()<\/code>.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">let date = new Date();\n\nlet year = date.getFullYear();\nconsole.log(&quot;Year: &quot; + year);  \/\/ Output: Year: current year\n\nlet month = date.getMonth() + 1;\nconsole.log(&quot;Month: &quot; + month);  \/\/ Output: Month: current month (0-11, so add 1)\n\nlet day = date.getDate();\nconsole.log(&quot;Day: &quot; + day);  \/\/ Output: Day: current day of the month\n\nlet hours = date.getHours();\nconsole.log(&quot;Hours: &quot; + hours);  \/\/ Output: Hours: current hour (0-23)\n\nlet minutes = date.getMinutes();\nconsole.log(&quot;Minutes: &quot; + minutes);  \/\/ Output: Minutes: current minute (0-59)\n\nlet seconds = date.getSeconds();\nconsole.log(&quot;Seconds: &quot; + seconds);  \/\/ Output: Seconds: current second (0-59)\n\nlet milliseconds = date.getMilliseconds();\nconsole.log(&quot;Milliseconds: &quot; + milliseconds);  \/\/ Output: Milliseconds: current millisecond (0-999)\n\nlet dayOfWeek = date.getDay();\nconsole.log(&quot;Day of the Week: &quot; + dayOfWeek);  \/\/ Output: Day of the Week: current day (0-6, Sunday=0)<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Setting Date and Time Values<\/strong><\/h2>\n\n\n\n<p>This example demonstrates how to set various parts of the date and time using methods like <code>setFullYear()<\/code>, <code>setMonth()<\/code>, <code>setDate()<\/code>, <code>setHours()<\/code>, <code>setMinutes()<\/code>, <code>setSeconds()<\/code>, and <code>setMilliseconds()<\/code>.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">let date = new Date();\n\ndate.setFullYear(2025);\nconsole.log(&quot;Year: &quot; + date.getFullYear());  \/\/ Output: Year: 2025\n\ndate.setMonth(11);  \/\/ December (0-11)\nconsole.log(&quot;Month: &quot; + (date.getMonth() + 1));  \/\/ Output: Month: 12\n\ndate.setDate(25);\nconsole.log(&quot;Day: &quot; + date.getDate());  \/\/ Output: Day: 25\n\ndate.setHours(10);\nconsole.log(&quot;Hours: &quot; + date.getHours());  \/\/ Output: Hours: 10\n\ndate.setMinutes(30);\nconsole.log(&quot;Minutes: &quot; + date.getMinutes());  \/\/ Output: Minutes: 30\n\ndate.setSeconds(45);\nconsole.log(&quot;Seconds: &quot; + date.getSeconds());  \/\/ Output: Seconds: 45\n\ndate.setMilliseconds(500);\nconsole.log(&quot;Milliseconds: &quot; + date.getMilliseconds());  \/\/ Output: Milliseconds: 500<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Parsing Dates<\/strong><\/h2>\n\n\n\n<p>You can create <code>Date<\/code> objects from date strings using the <code>Date.parse()<\/code> method or the <code>Date<\/code> constructor.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Explanation of Code: <\/strong><\/p>\n\n\n\n<p>The <code>Date.parse()<\/code> method parses a date string and returns the number of milliseconds since January 1, 1970, which can be used to create a <code>Date<\/code> object.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">let dateString = &quot;2024-11-11T12:00:00Z&quot;;\nlet parsedDate = new Date(Date.parse(dateString));\nconsole.log(parsedDate);  \/\/ Output: Parsed date and time<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Formatting Dates<\/strong><\/h2>\n\n\n\n<p>You can format dates using various methods like <code>toDateString()<\/code>, <code>toTimeString()<\/code>, <code>toLocaleDateString()<\/code>, <code>toLocaleTimeString()<\/code>, etc.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Explanation of Code:<\/strong><\/p>\n\n\n\n<p>This example demonstrates how to format dates using methods like <code>toDateString()<\/code>, <code>toTimeString()<\/code>, <code>toLocaleDateString()<\/code>, and <code>toLocaleTimeString()<\/code>.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;JavaScript&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">let date = new Date();\n\nconsole.log(&quot;Date String: &quot; + date.toDateString());  \/\/ Output: Date String: current date in readable format\nconsole.log(&quot;Time String: &quot; + date.toTimeString());  \/\/ Output: Time String: current time in readable format\n\nconsole.log(&quot;Locale Date String: &quot; + date.toLocaleDateString());  \/\/ Output: Locale Date String: current date in localized format\nconsole.log(&quot;Locale Time String: &quot; + date.toLocaleTimeString());  \/\/ Output: Locale Time String: current time in localized format<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>JavaScript Date and Time Example Code<\/strong><\/h2>\n\n\n\n<p><strong>Explanation of Code:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Creating a Date Object<\/strong>: Creates a <code>Date<\/code> object with the current date and time.<\/li>\n\n\n\n<li><strong>Getting Date Components<\/strong>: Retrieves various components of the date and time.<\/li>\n\n\n\n<li><strong>Setting Date Components<\/strong>: Updates various components of the date and time.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;HTML&quot;,&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}\">&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n    &lt;title&gt;JavaScript Date and Time Example&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;script&gt;\n        \/\/ Creating a new date object with specific values\n        let now = new Date(2024, 9, 11, 12, 41, 9, 714); \/\/ Month is 0-based (9 = October)\n\n        console.log(&quot;Current Date and Time: &quot; + now.toString());\n\n        console.log(&quot;Year: &quot; + now.getFullYear());\n        console.log(&quot;Month: &quot; + now.getMonth());\n        console.log(&quot;Date: &quot; + now.getDate());\n        console.log(&quot;Hours: &quot; + now.getHours());\n        console.log(&quot;Minutes: &quot; + now.getMinutes());\n        console.log(&quot;Seconds: &quot; + now.getSeconds());\n        console.log(&quot;Milliseconds: &quot; + now.getMilliseconds());\n        console.log(&quot;Day of the Week: &quot; + now.getDay());\n\n        \/\/ Setting updated date and time\n        let updatedDate = new Date();\n        updatedDate.setFullYear(2025);\n        updatedDate.setMonth(11); \/\/ December\n        updatedDate.setDate(25);\n        updatedDate.setHours(15);\n        updatedDate.setMinutes(30);\n        updatedDate.setSeconds(45);\n\n        console.log(&quot;Updated Date and Time: &quot; + updatedDate.toString());\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1919\" height=\"907\" src=\"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png\" alt=\"\" class=\"wp-image-231\" style=\"width:1200px;height:auto\" srcset=\"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png 1919w, https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409-300x142.png 300w, https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409-1024x484.png 1024w, https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409-768x363.png 768w, https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409-1536x726.png 1536w\" sizes=\"(max-width: 1919px) 100vw, 1919px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>JavaScript Labs<\/strong><\/h2>\n\n\n\n<iframe src=\"https:\/\/techkubo.com\/javascript-sim.html\" title=\"Try HTML on TechKubo\" width=\"100%\" height=\"500\"><\/iframe>\n","protected":false},"excerpt":{"rendered":"<p>Creating a Date Object The Date object is used to work with dates and times. You can create a new [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"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":[1],"tags":[],"class_list":["post-114","post","type-post","status-publish","format-standard","hentry","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript Date and Time - JavaScript Tutorial<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Date and Time - JavaScript Tutorial\" \/>\n<meta property=\"og:description\" content=\"Creating a Date Object The Date object is used to work with dates and times. You can create a new [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/\" \/>\n<meta property=\"og:site_name\" content=\"JavaScript Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-11T04:54:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-17T03:45:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1919\" \/>\n\t<meta property=\"og:image:height\" content=\"907\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Manong\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Manong\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/\"},\"author\":{\"name\":\"Manong\",\"@id\":\"https:\/\/techkubo.com\/javascript\/#\/schema\/person\/b4fa2f01fa4ff2a4e98276ce47115965\"},\"headline\":\"JavaScript Date and Time\",\"datePublished\":\"2024-11-11T04:54:23+00:00\",\"dateModified\":\"2025-05-17T03:45:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/\"},\"wordCount\":196,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/#organization\"},\"image\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png\",\"articleSection\":[\"javascript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/\",\"url\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/\",\"name\":\"JavaScript Date and Time - JavaScript Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png\",\"datePublished\":\"2024-11-11T04:54:23+00:00\",\"dateModified\":\"2025-05-17T03:45:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#primaryimage\",\"url\":\"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png\",\"contentUrl\":\"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png\",\"width\":1919,\"height\":907},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/techkubo.com\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Date and Time\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/techkubo.com\/javascript\/#website\",\"url\":\"https:\/\/techkubo.com\/javascript\/\",\"name\":\"JavaScript Tutorial\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/techkubo.com\/javascript\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/techkubo.com\/javascript\/#organization\",\"name\":\"JavaScript Tutorial\",\"url\":\"https:\/\/techkubo.com\/javascript\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techkubo.com\/javascript\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2025\/01\/cropped-Techkubo-logo-1.png\",\"contentUrl\":\"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2025\/01\/cropped-Techkubo-logo-1.png\",\"width\":1618,\"height\":1174,\"caption\":\"JavaScript Tutorial\"},\"image\":{\"@id\":\"https:\/\/techkubo.com\/javascript\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/techkubo.com\/javascript\/#\/schema\/person\/b4fa2f01fa4ff2a4e98276ce47115965\",\"name\":\"Manong\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techkubo.com\/javascript\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/21a7455736c21887b8fefe0935012d65?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/21a7455736c21887b8fefe0935012d65?s=96&d=mm&r=g\",\"caption\":\"Manong\"},\"sameAs\":[\"https:\/\/techkubo.com\"],\"url\":\"https:\/\/techkubo.com\/javascript\/author\/manong\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Date and Time - JavaScript Tutorial","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:\/\/techkubo.com\/javascript\/javascript-data-and-time\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Date and Time - JavaScript Tutorial","og_description":"Creating a Date Object The Date object is used to work with dates and times. You can create a new [&hellip;]","og_url":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/","og_site_name":"JavaScript Tutorial","article_published_time":"2024-11-11T04:54:23+00:00","article_modified_time":"2025-05-17T03:45:39+00:00","og_image":[{"width":1919,"height":907,"url":"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png","type":"image\/png"}],"author":"Manong","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Manong","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#article","isPartOf":{"@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/"},"author":{"name":"Manong","@id":"https:\/\/techkubo.com\/javascript\/#\/schema\/person\/b4fa2f01fa4ff2a4e98276ce47115965"},"headline":"JavaScript Date and Time","datePublished":"2024-11-11T04:54:23+00:00","dateModified":"2025-05-17T03:45:39+00:00","mainEntityOfPage":{"@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/"},"wordCount":196,"commentCount":0,"publisher":{"@id":"https:\/\/techkubo.com\/javascript\/#organization"},"image":{"@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#primaryimage"},"thumbnailUrl":"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png","articleSection":["javascript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/","url":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/","name":"JavaScript Date and Time - JavaScript Tutorial","isPartOf":{"@id":"https:\/\/techkubo.com\/javascript\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#primaryimage"},"image":{"@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#primaryimage"},"thumbnailUrl":"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png","datePublished":"2024-11-11T04:54:23+00:00","dateModified":"2025-05-17T03:45:39+00:00","breadcrumb":{"@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#primaryimage","url":"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png","contentUrl":"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2024\/11\/Screenshot-2025-05-17-114409.png","width":1919,"height":907},{"@type":"BreadcrumbList","@id":"https:\/\/techkubo.com\/javascript\/javascript-data-and-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techkubo.com\/javascript\/"},{"@type":"ListItem","position":2,"name":"JavaScript Date and Time"}]},{"@type":"WebSite","@id":"https:\/\/techkubo.com\/javascript\/#website","url":"https:\/\/techkubo.com\/javascript\/","name":"JavaScript Tutorial","description":"","publisher":{"@id":"https:\/\/techkubo.com\/javascript\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techkubo.com\/javascript\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techkubo.com\/javascript\/#organization","name":"JavaScript Tutorial","url":"https:\/\/techkubo.com\/javascript\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techkubo.com\/javascript\/#\/schema\/logo\/image\/","url":"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2025\/01\/cropped-Techkubo-logo-1.png","contentUrl":"https:\/\/techkubo.com\/javascript\/wp-content\/uploads\/sites\/7\/2025\/01\/cropped-Techkubo-logo-1.png","width":1618,"height":1174,"caption":"JavaScript Tutorial"},"image":{"@id":"https:\/\/techkubo.com\/javascript\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/techkubo.com\/javascript\/#\/schema\/person\/b4fa2f01fa4ff2a4e98276ce47115965","name":"Manong","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techkubo.com\/javascript\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/21a7455736c21887b8fefe0935012d65?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/21a7455736c21887b8fefe0935012d65?s=96&d=mm&r=g","caption":"Manong"},"sameAs":["https:\/\/techkubo.com"],"url":"https:\/\/techkubo.com\/javascript\/author\/manong\/"}]}},"_links":{"self":[{"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/posts\/114"}],"collection":[{"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":4,"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":232,"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/posts\/114\/revisions\/232"}],"wp:attachment":[{"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techkubo.com\/javascript\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}