Deprecated: Hook custom_css_loaded is deprecated since version jetpack-13.5! Use WordPress Custom CSS instead. Jetpack no longer supports Custom CSS. Read the WordPress.org documentation to learn how to apply custom styles to your site: https://wordpress.org/documentation/article/styles-overview/#applying-custom-css in /home/everyuseful/public_html/wp-includes/functions.php on line 6078
How to get the current date as yyyy-mm-dd in Javascript - EveryUseful

How to get the current date as yyyy-mm-dd in Javascript

If you want to get the current date in the format of yyyy-mm-dd using Javascript you can do:

new Date().toISOString().split('T')[0];

Where new Date() gets the date as :
Fri Mar 11 2022 11:04:44 GMT+0200 (Eastern European Standard Time) {}

.toISOString() convert it to: 2022-03-11T09:03:38.056Z

and as we need only the date, we split it and get the first part by: .split(‘T’)[0]

Leave a Reply

Your email address will not be published. Required fields are marked *