{"id":12265,"date":"2022-08-03T13:31:59","date_gmt":"2022-08-03T17:31:59","guid":{"rendered":"http:\/\/local.brightwhiz\/?post_type=snippets&p=12265"},"modified":"2022-08-03T13:32:02","modified_gmt":"2022-08-03T17:32:02","slug":"use-vanilla-javascript-to-format-a-date-snippet","status":"publish","type":"snippets","link":"http:\/\/local.brightwhiz\/snippets\/use-vanilla-javascript-to-format-a-date-snippet\/","title":{"rendered":"How to Use Vanilla JavaScript to Format a Date"},"content":{"rendered":"\n
In this example snippet we will vanilla JavaScript to format a date in this format dd\/mm\/yyyy<\/code>.<\/p>\n\n\n\n
var today = new Date();\nvar dd = String(today.getDate()).padStart(2, '0');\nvar mm = String(today.getMonth() + 1).padStart(2, '0'); \/\/January is 0!\nvar yyyy = today.getFullYear();\ntoday = dd + '\/' + mm + '\/' + yyyy;\n\nconsole.log(today);<\/code><\/pre>\n","protected":false},"comment_status":"open","ping_status":"closed","template":"","meta":[],"categories":[953,27,15,16],"tags":[328,433,449,471,638],"yoast_head":"\n