Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how get start and end current week #255

Open
mohsenmehri6101 opened this issue Sep 24, 2023 · 5 comments
Open

how get start and end current week #255

mohsenmehri6101 opened this issue Sep 24, 2023 · 5 comments

Comments

@mohsenmehri6101
Copy link

how can get the stat and end from current week.

example if today is 1402-06-18 (سه شنبه) get :
start : 1402-06-15
end : 1402-06-21
???

@mohsenmehri6101
Copy link
Author

@behrang

@ngtive
Copy link

ngtive commented Oct 13, 2023

@mohsenmehri6101

const startOfCurrentWeek = moment().startOf("week").startOf("day")
const endOfCurrentWeek = moment().endOf("week").endOf("day")

@mohsenmehri6101
Copy link
Author

@ngtive
thanks for your answer .but this code get start week georgian (sunday) . but should be get saterday.
and too about end week.

@behrang
Copy link
Member

behrang commented Nov 14, 2023

If I remember correctly, week start day has no relation to the calendar system. I think in moment, you can change week start day or set it using a locale. Then you can do the calculations that you want.

@1mehdifaraji
Copy link
Contributor

@mohsenmehri6101 You can get the jalaali calendar start and end of the week like this:

moment().locale("fa").startOf("jWeek").format("jYYYY/jMM/jDD");
moment().locale("fa").endOf("jWeek").format("jYYYY/jMM/jDD");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants