Lakshman Pilaka
Lakshman Pilaka

Reputation: 1951

check if a date falls in the last week using date.js

i use date.js for doing certain date calculations.

i am able to find if the date falls in this week, the following returns true

dateFld.between(Date.monday(), Date.friday())

but I want to check if date falls in the previous week.

i am using the following code without luck.

alert(dateFld.between(Date.last().week().monday(), Date.last().week().sunday()));

please help.

Upvotes: 2

Views: 430

Answers (1)

BenG
BenG

Reputation: 15154

Sunday is the first day of the week.

Date.last().week().monday()

Mon Sep 07 2015 00:00:00 GMT+0100 (GMT Daylight Time) Correct

Date.last().week().sunday()

Sun Sep 06 2015 00:00:00 GMT+0100 (GMT Daylight Time) Incorrect

Date.last().sunday()

Sun Sep 13 2015 00:00:00 GMT+0100 (GMT Daylight Time) Correct

Upvotes: 1

Related Questions