i'm trying next business day code, it's not working correctly. it's showing next day. i've tried check other questions find error, still can't figure out.
this question applies own not exactly:
how exclude weekends between 2 dates using moment.js
$scope.businessday = new date(); if (moment().day() === 5) { // friday, show monday // set monday $scope.businessday=moment().weekday(8).format("mmmm yyyy"); } if (moment().day() === 6) { // saturday, show monday // set monday $scope.businessday=moment().weekday(8).format("mmmm yyyy"); } else { // other days, show next day $scope.businessday= moment().add('days', 1).format("mmmm yyyy"); }
it's working fine. you've missed else
if (moment().day() === 5) { // friday, show monday // set monday $scope.businessday=moment().weekday(8).format("mmmm yyyy"); --> } else if (moment().day() === 6) { // saturday, show monday // set monday $scope.businessday=moment().weekday(8).format("mmmm yyyy"); } else { // other days, show next day $scope.businessday= moment().add('days', 1).format("mmmm yyyy"); }
Comments
Post a Comment