Defining Weekdays for Calendar in PHP

Aspose.Tasks - Defining Weekdays for Calendar

To Define Weekdays for Calendar using Aspose.Tasks Java for PHP, simply invoke DefineWeekdaysForCalendar module. Here you can see example code.

 1$project = new Project();
 2$cal = $project->getCalendars()->add("Calendar1");
 3$weekday = new WeekDay();
 4$dayType = new DayType();
 5$cal->getWeekDays()->add($weekday->createDefaultWorkingDay($dayType->Monday));
 6$cal->getWeekDays()->add($weekday->createDefaultWorkingDay($dayType->Tuesday));
 7$cal->getWeekDays()->add($weekday->createDefaultWorkingDay($dayType->Wednesday));
 8$cal->getWeekDays()->add($weekday->createDefaultWorkingDay($dayType->Thursday));
 9$cal->getWeekDays()->add(new WeekDay($dayType->Saturday));
10$cal->getWeekDays()->add(new WeekDay($dayType->Sunday));
11$myWeekDay = new WeekDay($dayType->Friday);
12$wt1 = new WorkingTime();
13$calendar = new Calendar();
14$calTime = $calendar->getInstance();
15$calTime->set(1,1,1,9,0,0);
16$date = $calTime->getTime();
17$time1->setFromTime($date);
18$calTime->set(1,1,1,12,0,0);
19$date = $calTime->getTime();
20$time1->setToTime($date);
21$time2 = new WorkingTime();
22$calTime->set(1,1,1,13,0,0);
23$date = $calTime->getTime();
24$time2->setFromTime($date);
25$calTime->set(1,1,1,16,0,0);
26$date = $calTime->getTime();
27$time2->setToTime($date);
28$myWeekDay->getWorkingTimes()->add($time1);
29$myWeekDay->getWorkingTimes()->add($time2);
30$myWeekDay->setDayWorking(true);
31$cal->getWeekDays()->add($myWeekDay);
32$saveFileFormat = new SaveFileFormat();
33$project->save("CalendarWeekdays.xml", $saveFileFormat->XML);
34print "Defined weekdays for calendar, please check the output file.";

Download Running Code

Download Defining Weekdays for Calendar (Aspose.Tasks) from any of the below mentioned social coding sites:

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.