Define "doesn't work".

const date = moment("2015-07-02"); // Thursday Feb 2015
const dow = date.day();
console.log(dow);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>

This prints "4", as expected.

Answer from c0xc on Stack Overflow
🌐
Readthedocs
momentjscom.readthedocs.io › en › latest › moment › 02-get-set › 06-day
Day of Week - momentjs.com
This method can be used to set the day of the week, with Sunday as 0 and Saturday as 6. If the value given is from 0 to 6, the resulting date will be within the current (Sunday-to-Saturday) week. If the range is exceeded, it will bubble up to other weeks. moment().day(-7); // last Sunday (0 ...
🌐
Moment.js
momentjs.com › docs
Moment.js | Docs
Note: Moment#date is for the date of the month, and Moment#day is for the day of the week. As of 2.1.0, a day name is also supported. This is parsed in the moment's current locale. ... Gets or sets the day of the week according to the locale.
🌐
TutorialsPoint
tutorialspoint.com › home › momentjs › moment.js day of the week
Moment.js Day of the Week
October 22, 2018 - As per the locale, if Sunday is set as the first day of week, you will have to set moment.weekday(0) to Sunday.
🌐
GitHub
github.com › moment › momentjs.com › blob › master › docs › moment › 02-get-set › 07-weekday.md
momentjs.com/docs/moment/02-get-set/07-weekday.md at master · moment/momentjs.com
As with moment#day, if the range is exceeded, it will bubble up to other weeks. // when Monday is the first day of the week moment().weekday(-7); // last Monday moment().weekday(7); // next Monday // when Sunday is the first day of the week moment().weekday(-7); // last Sunday moment().weekday(7); // next Sunday
Author   moment
🌐
Readthedocs
momentjscom.readthedocs.io › en › latest › moment › 02-get-set › 07-weekday
Day of Week (Locale Aware) - momentjs.com
Gets or sets the day of the week according to the locale. If the locale assigns Monday as the first day of the week, moment().weekday(0) will be Monday.
🌐
Today I Learned
til.hashrocket.com › posts › cxd9yl95ip--get-beginning-and-end-of-week-with-momentjs
Today I Learned: 📅 Get beginning and end of week with Moment.js
November 12, 2024 - const today = moment(); const from_date = today.startOf('week'); const to_date = today.endOf('week'); console.log({ from_date: from_date.toString(), today: moment().toString(), to_date: to_date.toString(), }); // { // from_date: "Sun Apr 22 2018 00:00:00 GMT-0500", // today: "Thu Apr 26 2018 15:18:43 GMT-0500", // to_date: "Sat Apr 28 2018 23:59:59 GMT-0500" // } NOTE: Remember that the start of week will depend on the user's locale settings on their machine.
🌐
GeeksforGeeks
geeksforgeeks.org › node.js › moment-js-moment-weekdaynumber-method
Moment.js moment().weekday(Number) Method - GeeksforGeeks
July 12, 2022 - The moment().weekday() method is used to get or set the weekday of the Moment object. It is locale aware hence the value can depend based on whether the first day of the week is a Sunday or Monday.
🌐
GeeksforGeeks
geeksforgeeks.org › moment-js-moment-day-method
Moment.js moment().day() Method | GeeksforGeeks
September 19, 2024 - The moment().day() method in Moment.js returns or sets the day of the week for a moment object, where Sunday is represented as 0 and Saturday as 6.
Find elsewhere
🌐
Reddit
reddit.com › r/obsidianmd › get start and end date of a week moment js
r/ObsidianMD on Reddit: Get start and end date of a week moment JS
March 7, 2023 -

Hello, I am working with version 1.1.16 of Obsidian and trying to move from daily to weekly notes.

  1. How do I print the first and the end date of the week? The Moment JS documentation suggests the following two options

- `moment#endOf('week')` -

- `moment().startOf('week')` - I am certain this won't be possible since this is the JS way.

2. Is there a way to evaluate JS expressions as well?

3. How do I print all the dates and the day incrementally in that week?

EDIT - additionally I want to understand how does the evaluation of such expressions works in Obsidian. Currently I am only able to leverage these expressions when using a template.

🌐
Readthedocs
momentjscom.readthedocs.io › en › latest › moment › 02-get-set › 08-iso-weekday
ISO Day of Week - momentjs.com
Gets or sets the ISO day of the week with 1 being Monday and 7 being Sunday. As with moment#day, if the range is exceeded, it will bubble up to other weeks.
🌐
CodePen
codepen.io › ddrevnov › pen › BKMMej
moment.js get current week array
var startOfWeek = moment().startOf('isoWeek'); var endOfWeek = moment().endOf('isoWeek'); var days = []; var day = startOfWeek; while (day <= endOfWeek) { days.push(day.toDate()); day = day.clone().add(1, 'd'); } console.log(days);
🌐
GitHub
github.com › moment › moment › issues › 4783
moment.weekdays() and moment.localeData().weekdays() have different function signature · Issue #4783 · moment/moment
August 15, 2018 - Normally, you can get a list of weekdays like so: moment.weekdays() and if you want them ordered in a localized way (such as Montag/monday as first day of week for Germany) you can do moment.weekdays(true)
Author   andyford
🌐
IQCode
iqcode.com › code › javascript › moment-get-week-day
moment get week day Code Example
og(dayStr + &quot; &quot; + test(moment(dayStr)) ); } //examples from the console: //2014-01-8 Wed number 2 of the month //2014-01-13 Mon number 2 of the month //2014-01-20 Mon number 3 of the month //2014-01-27 Mon number 4 of the month //2014-01-29 Wed number 5 of the month ... ...
🌐
ZetCode
zetcode.com › javascript › momentjs
Moment.js Tutorial - Simplifying Date and Time
$ node parts.js Year: 2018 Month: 6 Date: 2 Hour: 18 Minute: 10 Second: 3 Millisecond: 329 · The following example calculates the day of week, month, and year. ... const moment = require('moment'); let now = moment(); console.log("Day of week: " + now.weekday()); console.log("Day of month: ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-day-of-week-number-in-momentjs
How To Get Day of Week Number in Moment.js? - GeeksforGeeks
July 23, 2025 - This method is based on the ISO weekday numbering system. ... const moment = require('moment'); let date = moment('2024-07-26'); let dayNumber = date.day(); console.log(`The day of the week for 2024-07-26 is: ${dayNumber}`);
🌐
Readthedocs
momentjscom.readthedocs.io › en › latest › moment › 06-i18n › 07-listing-months-weekdays
Listing the months and weekdays of the current Moment.js locale - momentjs.com
You can pass an integer into each of those functions to get a specific month or weekday. moment.weekdays(3); // 'Wednesday' As of 2.13.0 you can pass a bool as the first parameter of the weekday functions. If true, the weekdays will be returned in locale specific order. For instance, in the Arabic locale, Saturday is the first day of the week, thus: moment.locale('ar'); moment.weekdays(true); // lists weekdays Saturday-Friday in Arabic moment.weekdays(true, 2); //will result in Monday in Arabic ·
🌐
GitHub
github.com › moment › moment › issues › 4426
Get single letter abbreviation of week day. · Issue #4426 · moment/moment
October 30, 2017 - Description of the Issue and Steps to Reproduce: I need to get single letter abbreviation of week day e.g. R for Thursday, F for Friday, S for Saturday, U for Sunday. Using moment().format('d') give the number of the day of the week. Is ...
Author   mhasbini
🌐
Readthedocs
momentjscom.readthedocs.io › en › latest › moment › 07-customization › 16-dow-doy
First Day of Week and First Week of Year - momentjs.com
// Deprecated in 2.8.1 moment.lang('en', { week : { dow : Int, doy : Int } }); Locale#week.dow should be an integer representing the first day of the week, 0 is Sunday, 1 is Monday, ..., 6 is Saturday.