Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to display the day of the week on a button?

Is it possible to automatically display the day of the week on a button?

See the markup below, I need to make "Monday" show whatever day of the week it is.

<button class="button">Conquer Monday</button>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You could use Date::toLocaleDateString to display the current week day:

document.querySelector('.button').textContent = 'Conquer ' + new Date().toLocaleDateString('en-us', {weekday:'long'});
<button class="button"></button>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading