quma
quma

Reputation: 5733

How to check in javascript if date is a monday

I have this dateTime - picker and now I will only allow (all) mondays:

<input type="text"
    class="form-control scheduleFrom"
    name="scheduleFrom"                                
    ng-model="vm.scheduleIntervalContainerWeeksFrom"
    datepicker-popup="dd.MM.yyyy"
    is-open="vm.openedDatePickerFrom"
    close-text="schlie&szlig;en"
    current-text="heute"
    clear-text="l&ouml;schen"
    date-disabled="vm.disabledFrom(date, mode)">

Currently this is my disable- function:

vm.disabledFrom = function(date, mode) { 
    return mode === 'day' && date < vm.scheduleIntervalContainerWeeksFrom;
};

Thanks for any hints

Upvotes: 0

Views: 2017

Answers (2)

misss-popcorn
misss-popcorn

Reputation: 600

Try out the following link ,it may help-- http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_date_weekday

Upvotes: 0

GG.
GG.

Reputation: 21854

To check that your date is a Monday:

date.getDay() === 1

See Date.prototype.getDay().

Upvotes: 3

Related Questions