{"flag":true,"single":true,"pageTitle":"Dates In Javascript","post":{"id":205,"user_id":"1","slug":"dates-in-javascript-xhte","title":"Dates In Javascript","body":"<p>DATE<\/p>\r\n<ul>\r\n<li>new Date(); \/\/current date and time:<\/li>\r\n<li>new Date(year, month, day, hours, minutes, seconds, milliseconds);\/\/specified date and time. &amp; at least two parameters used<\/li>\r\n<li>new Date(milliseconds); \/\/from 01\/01\/1970 00:00:00 to millisecons<\/li>\r\n<li>new Date(date string); \/\/ie var d = new Date(\"October 13, 2014 11:13:00\");<\/li>\r\n<li>var d = new Date(); \/\/Sat, 21 Dec 2019 16:21:36&nbsp;<\/li>\r\n<\/ul>\r\n<pre class=\"language-markup\"><code>document.getElementById(\"demo\").innerHTML = d.toUTCString(); \/\/to UTC (CORDINATE UNIVERSAL TIME) Sat, 21 Dec 2019 16:21:36 GMT<\/code><\/pre>\r\n<p>d.toDateString(); \/\/Sat Dec 21 2019<\/p>\r\n<p><strong>FORMATES:<\/strong><\/p>\r\n<p>var d = new Date(\"2015-03-25\"); \/\/<\/p>\r\n<p>var d = new Date(\"2015\"); \/\/<\/p>\r\n<p><strong>GET METHODS:<\/strong><\/p>\r\n<p>var d = new Date();<\/p>\r\n<p>document.getElementById(\"demo\").innerHTML = d.getTime();<\/p>\r\n<ul>\r\n<li>d.getFullYear();<\/li>\r\n<li>d.getMonth();<\/li>\r\n<li>d.getDate();<\/li>\r\n<li>d.getHours();<\/li>\r\n<li>d.getMinutes();<\/li>\r\n<li>d.getSeconds();<\/li>\r\n<li>d.getMilliseconds();<\/li>\r\n<li>d.getDay();<\/li>\r\n<\/ul>\r\n<p><strong>SET METHODS:<\/strong><\/p>\r\n<ul>\r\n<li>d.setFullYear(2020);<\/li>\r\n<li>setDate() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set the day as a number (1-31)<\/li>\r\n<li>setFullYear() &nbsp; &nbsp; &nbsp; Set the year (optionally month and day)<\/li>\r\n<li>setHours() &nbsp; &nbsp; &nbsp; Set the hour (0-23)<\/li>\r\n<li>setMilliseconds()&nbsp; &nbsp;Set the milliseconds (0-999)<\/li>\r\n<li>setMinutes() &nbsp; &nbsp; &nbsp; Set the minutes (0-59)<\/li>\r\n<li>setMonth() &nbsp; &nbsp; &nbsp; Set the month (0-11)<\/li>\r\n<li>setSeconds() &nbsp; &nbsp; &nbsp; Set the seconds (0-59)<\/li>\r\n<li>setTime() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set the time (milliseconds since January 1, 1970)<\/li>\r\n<\/ul>\r\n<p>JavaScript counts months from 0 to 11.<\/p>","category_id":"12","is_private":"0","created_at":"2023-10-13T01:33:37.000000Z","updated_at":"2023-10-13T01:33:37.000000Z","category":{"id":12,"user_id":"1","name":"Javascript","slug":"javascript-xplw","parent_id":null,"created_at":"2023-03-23T02:24:43.000000Z","updated_at":"2023-03-23T02:24:43.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"DATE  new Date(); \/\/current date and time: new Date(year, month, day, hours, minutes, seconds, milliseconds);\/\/specified date and time. &amp - Dates In Javascript (Updated: October 13, 2023) - Read more about Dates In Javascript at my programming site [SITE]","categories":[]}