The second().period().weeks() methodology is used to get the weeks of the period. This variety of weeks is calculated as a subset of the times, due to this fact having a price between 0 and 4. The size of days for calculating every week is 7 days.
This methodology is completely different from the asWeeks() methodology which returns the size of the given period in weeks.
Syntax:
second().period().weeks();
Parameters: This methodology doesn’t settle for any parameters.
Return Worth: This methodology returns the weeks (0-4) of the period.
Word: This won’t work within the regular Node.js program as a result of it requires an exterior second.js library to be put in globally or within the venture listing.
Second.js might be put in utilizing the next command:
Set up of second module:
npm set up second
The under examples will show the Second.js second.period().weeks() Methodology.
Instance 1:Â
Javascript
|
Output:
durationOne Weeks is: 3 durationTwo Weeks is: 1
Instance 2: This instance will assist to grasp the distinction of this methodology with asWeeks() for a greater understanding.
Javascript
|
Output:
Size of durationA in weeks is: 4.285714285714286 durationA Weeks is: 4 Size of durationB in weeks is: 5.428571428571429 durationB Weeks is: 1
Reference: https://momentjs.com/docs/#/durations/weeks/