search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to show current month on button click?

Asked by Akhtar Raza
1 year ago.

I'm using Daypilot Day, Month, and Week view. I added today's button for all 3 views. When I click on the today button for Day and week, it's working fine but when I click on today for the month view, it's not working.

Below is my code.

currentDate(date: DayPilot.Date): void {
this.configDay.startDate = date;
this.configWeek.startDate = date;
let dt = new DayPilot.Date(this.configWeek.startDate || this.configDay.startDate || this.configMonth.startDate);
this.dateString = dt.toString("MMMM d, yyyy")
}

Comment posted by Akhtar Raza
1 year ago.

I Want to show the current month according to the system time date. Week and Date is working accordingly system date.

Answer posted by Dan Letecky [DayPilot]
12 months ago.

It looks like you are missing "configMonth" change in your method:

currentDate(date: DayPilot.Date): void {
  this.configDay.startDate = date;
  this.configWeek.startDate = date;
  this.configMonth.startDate = date;
  let dt = new DayPilot.Date(this.configWeek.startDate || this.configDay.startDate || this.configMonth.startDate);
  this.dateString = dt.toString("MMMM d, yyyy")
}
Comment posted by Akhtar Raza
12 months ago.

Sorry about that. I already used this but forget to mention it in the code. When I used this I get an error like
"this.startDate.firstDayOfMonth is not a function " in console.

this is my code for the month on function changeDate()

let dt = new DayPilot.Date(this.configMonth.startDate).addMonths(value * 1).firstDayOfMonth();

let day = dt.toString("dddd");
if (day == "Saturday") {
dt = dt.addDays(value > 0 ? value * 2 : value * 1);
} else if (day == "Sunday") {
dt = dt.addDays(value > 0 ? value * 1 : value * 2);
}

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.