Get the Day of the Week in JavaScript #Call the Show
In the first example, we used the getDay method to get an integer from Our second example uses the toLocaleString method to get the name of the day of the week. We passed the following arguments to the method:
If you want to get the day's name in a different locale, pass the locale as the first parameter to the method.
If you need to get the day's name in a different format, e.g. the first 3 letters or just the first letter, update the value of the
Setting the day to Further Reading #
JavaScript Datetime: Exercise-20 with SolutionWrite a JavaScript function to get a textual representation of a day (three letters, Mon through Sun). Test Data: Sample Solution:- HTML Code:
JavaScript Code:
Sample Output: Tue Sun Flowchart: Live Demo: See the Pen JavaScript - Get a textual representation of a day-date-ex-20 by w3resource (@w3resource) on CodePen. Improve this sample solution and post your code through Disqus Previous: Write a JavaScript function to get the day of the month, 2 digits with leading zeros. JavaScript: Tips of the DayImported module // counter.js let counter = 10; export default counter; // index.js import myCounter from './counter'; myCounter += 1; console.log(myCounter); An imported module is read-only: you cannot modify the imported module. Only the module that exports them can change its value. Ref: https://bit.ly/323Y0P6 |