Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between week of year and week of year ISO tokens (moment.js)

Tags:

momentjs

I was studying date formating in moment.js and I came across these tokens: Is there any significant difference between WoY and WoY ISO?

Week of Year

w - 1 2 ... 52 53  
wo - 1st 2nd ... 52nd 53rd  
ww - 01 02 ... 52 53

Week of Year (ISO)

W - 1 2 ... 52 53  
Wo - 1st 2nd ... 52nd 53rd  
WW - 01 02 ... 52 53
like image 576
Adrian Moisa Avatar asked Aug 20 '15 13:08

Adrian Moisa


People also ask

What is difference between ISO week and week?

According to Wikipedia, the ISO week counter starts the first thursday of the year; so, if the first day of the year is saturday, the first thursday will be in the next week. Thus, the ISO week of the first thursday will be the first, but the standard week of the first thursday will be the second, e.g. Regards!

What is _D and _I in moment?

_i will never be a moment object. _i can also be undefined, in the case of creating the current moment with moment() . _d is the instance of the Date object that backs the moment object. If you are in "local mode", then _d will have the same local date and time as the moment object exhibits with the public API.

How do you find the difference between two dates in a moment?

If you are using a date and time field and would like to output the difference between the two dates in days, hours and minutes, use the following template: var m1 = moment('{admission}', 'DD-MM-YYYY HH:mm'); var m2 = moment('{discharge}', 'DD-MM-YYYY HH:mm'); var m3 = m2. diff(m1,'minutes'); var m4 = m2.

Is MomentJS deprecated?

Moment construction falls back to js Date. This is discouraged and will be removed in an upcoming major release. This deprecation warning is thrown when no known format is found for a date passed into the string constructor.

What is the ISO week date system?

The ISO week date system is effectively a leap week calendar system that is part of the ISO 8601 date and time standard issued by the International Organization for Standardization (ISO) since 1988 (last revised in 2019) and, before that, it was defined in ISO (R) 2015 since 1971.

How to calculate the day of the week month and year?

The following example calculates the day of week, month, and year. The weekday () returns the day of week, the date () returns the day of month, and the dayOfYear () returns the day of year. This is a sample output. In the following example, we get the week of the year, the quarter of the year, and the number of weeks in the year.

What is the difference between weeknum and isoweeknum function?

Lets learn first about Weeknum function. Weeknum Function - This function helps to find the week number for a particular date in the same year. And it calculates week number based on users need (on weekdays basis). To know more about Weeknum Function click here. ISOweeknum Function - This function has the same working as Weeknum function.

How many weeks are there in a year?

An ISO week-numbering year (also called ISO year informally) has 52 or 53 full weeks. That is 364 or 371 days instead of the usual 365 or 366 days. These 53 week years occur on all years that have Thursday as the 1st of January and on leap years that start on Wednesday the 1st.


1 Answers

According to Wikipedia, the ISO week counter starts the first thursday of the year; so, if the first day of the year is saturday, the first thursday will be in the next week.

Thus, the ISO week of the first thursday will be the first, but the standard week of the first thursday will be the second, e.g.

moment('2005-01-02').isoWeek(); // 53
moment('2005-01-02').week(); // 1
moment('2005-01-03').isoWeek(); // 1
moment('2005-01-03').week(); // 2

Regards!

like image 168
Guillermo Alejandro Avatar answered Oct 12 '22 13:10

Guillermo Alejandro