Thursday, June 16, 2022
HomeWordPress DevelopmentSecond.js second.period().weeks() Methodology - GeeksforGeeks

Second.js second.period().weeks() Methodology – GeeksforGeeks


View Dialogue

Enhance Article

Save Article

Like Article

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

const second = require('second');

  

let durationOne = second.period(3, 'weeks');

let durationTwo = second.period(6, 'weeks');

  

console.log(

  "durationOne Weeks is:", durationOne.weeks()

)

  

console.log(

  "durationTwo Weeks is:", durationTwo.weeks()

)

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

const second = require('second');

  

let durationA = second.period(30, 'days');

let durationB = second.period(38, 'days');

  

console.log(

  "Size of durationA in weeks is:",

  durationA.asWeeks()

)

  

console.log(

  "durationA Weeks is:", durationA.weeks()

)

  

console.log(

  "Size of durationB in weeks is:",

  durationB.asWeeks()

)

console.log(

  "durationB Weeks is:", durationB.weeks()

)

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/

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments