Assalamualaikum ustaz. It is known that the ruling for jamak and qasar for a traveller mustn’t exceed three days. The question is, what is meant by the day one enters or exits a place?
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions and all those who follow his footsteps until the Last Day.
In al-Fiqh al-Manhaji (1/186) it is stated that one of the valid conditions of jama’ and qasar for a traveller is: “One doesn’t intend to stay at the destination for four days excluding the day he arrives and the day he leaves.”
This is based on the hadith from al-‘Ala’ bin al-Hadrami where the Prophet PBUH said:
يُقِيمُ الْمُهَاجِرُ بِمَكَّةَ بَعْدَ قَضَاءِ نُسُكِهِ ثَلَاثًا
“The Muhijir should stay at Mecca after performing the rituals (of Hajj) but for three (days) only.” 
This may confuse some; what is meant by the day one enters and leaves? Do these days mean the whole 24 hours of the first and final day or otherwise? In answering this issue, we cite the words of Imam al-Nawawi: “It is not included in the four days the two daytimes of him entering and leaving according to the sahih opinion.” Refer Minhaj al-Tolibin (pg. 44)
In the book Hasyiah al-Syirwani `ala Tuhfah al-Muhtaj (2/377), it is stated: [(And it is not included from the four days two daytimes of him entering)  which means only the night of the day he enters is calculated. The same for the daytime of the night he enters]
It is further explained: “[(or the two nights when he enters) which means the day and night of when he enters is not calculated or the same if the situation is of the opposite].”
According to the above discussion, there is a difference regarding the usage of the term day which means 24 hours and the “day” used in the context of the ruling of jama’ and qasar. “Day” used in the ruling means the daytime and night of when a traveller arrives or leaves the destination. For example, if a person arrives on Monday at day time, then he has to set his intention that he will return home or leave and travel to another faraway place during the day on Friday. If he returns on Saturday, then his jama’ and qasar prayer is invalid because it does not fulfil the valid conditions.
Furthermore, it should be understood that the change of days in Islam is after Maghrib (sunset) and not at midnight. Among the wisdoms of the facilitation given for the day of arrival and return is so that surely, he would be busy with the matters of his travel (such as transport, accommodation and the preparation for his return) on the daytime of these two days. 
We include a table for a better understanding:
(Arrival at destination)
Table 1: If a traveller arrives during the day.
Explanation for Table 1: For example, Abu Bakar arrives in Ipoh (long-distance travel destination) from Kuala Lumpur (his house or starting point of his journey) at 11.00 a.m. Monday morning. He has to set his intention to return to his house or travel to another place far on Friday (during the day). If he intends to leave on Friday night, then it is impermissible for him to perform jama’ and qasar prayer throughout his stay at Ipoh. Although during his travelling days it is permissible.
(Arrival at destination)
Table 2: If a traveller arrives at night.
Explanation for Table 2: For example, Umar arrives in Ipoh from Kuala Lumpur (his house or starting point of his journey) at 9.00 p.m. on Sunday. He has to set his intention to return to his house or travel to another far place on Thursday night. If he intends to leave on Friday, then it is impermissible for him to perform jama’ and qasar prayer throughout his stay in Ipoh. However, during the days he is travelling, it is not an issue
The above opinion is the final and sahih opinion in madhhab al-Syafie. This is our opinion and it will be easier to calculate. There is another opinion in other madhhabs such as the opinion stated by Imam al-Khatib al-Syirbini: “Imam al-Subki (a Syafi’ite scholar) chose the opinion of madhhab Imam Ahmad where the facilitation (to perform qasar during one’s travel) is not related to the number of days, consequently, it is related to the number of prayers. Thus, a traveller can take this facilitation with a total of 21 times obligatory prayers. The reason is this has been done by the Prophet PBUH when he was travelling to the area of al-Abtoh. According to a sahih opinion, it is a total of 23 times of prayer,” 
Table 3: If a traveller follows the opinion of Imam al-Subki.
Explanation for Table 3: For example, Abdullah arrives in Ipoh Kuala Lumpur (his house or starting point of his journey) at 9.30 a.m. on Monday. It is permissible for him to perform jama’ and qasar starting from Zuhur prayer on Monday until the Zuhr prayer on Friday.
To conclude, a traveller should set his intention to stay for only three days at the destination of his travels to make it permissible for him to get the facilitation of jama’ and qasar. This does not include the day or night of when he arrives at his travel destination and return back home. If all the days are calculated it can be up to a total of five days.
 See Minhaj al-Talibin, pg. 44
 This is the words of Imam Ibn Hajar al-Haitami in Tuhfah al-Muhtaj, while the explanatory hasyiah is given by Syeikh Abdul Hamid al-Syirwani
 The same as the fatwa issued by Syeikh Ali Syubramallisi.
 See Mughni al-Muhtaj, 1/519
 See Mughni al-Muhtaj, 1/520