{"id":543,"date":"2024-06-05T14:42:09","date_gmt":"2024-06-05T14:42:09","guid":{"rendered":"https:\/\/beinthecloud.biz\/sfdc\/1\/?p=543"},"modified":"2024-06-05T14:42:09","modified_gmt":"2024-06-05T14:42:09","slug":"get-the-current-date-in-javascript","status":"publish","type":"post","link":"https:\/\/beinthecloud.biz\/sfdc\/1\/2024\/06\/05\/get-the-current-date-in-javascript\/","title":{"rendered":"Get the current date in JavaScript"},"content":{"rendered":"\n<p>To get the current date in JavaScript, you can use the <code>Date<\/code> object. Here is a simple example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create a new Date object\r\nlet today = new Date();\r\n\r\n\/\/ Get the current date components\r\nlet year = today.getFullYear();\r\nlet month = today.getMonth() + 1; \/\/ Months are zero-based, so we add 1\r\nlet day = today.getDate();\r\n\r\n\/\/ Format the date as desired (e.g., YYYY-MM-DD)\r\nlet formattedDate = year + '-' + (month &lt; 10 ? '0' : '') + month + '-' + (day &lt; 10 ? '0' : '') + day;\r\n\r\nconsole.log(formattedDate);\r\n<\/code><\/pre>\n\n\n\n<p>This code will output the current date in the format <code>YYYY-MM-DD<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To get the current date in JavaScript, you can use the Date object. Here is a simple example: This code will output the current date in the format YYYY-MM-DD.<\/p>\n","protected":false},"author":1,"featured_media":544,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[16],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-content\/uploads\/2024\/06\/JavaScript-Logo-scaled.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/posts\/543"}],"collection":[{"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":1,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/posts\/543\/revisions"}],"predecessor-version":[{"id":545,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/posts\/543\/revisions\/545"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/media\/544"}],"wp:attachment":[{"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/media?parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}