Question: Is it true that one may not take a haircut in the afternoon or at night?
Answer: Sefer Chemdat Yamim (Laws of Erev Shabbat) writes that it is proper to take a haircut before halachic midday, for after this time, Heavenly judgment begins to increase and since a haircut symbolizes removal of judgment, it is inappropriate to perform such an action when the attribute of judgment is in control. According to this, one should only take a haircut during the morning hours, not in the afternoon or night.
Although we may not understand these deep Kabbalistic concepts completely, we can understand that Heavenly judgement begins to manifest itself in the world during the afternoon and since a haircut represents the antithesis of this, it is not an appropriate time to do so.
Indeed, Rabbeinu Chaim Vital writes (in his Shaar Ha’Mitzvot) that his teacher, the saintly Ari z”l, would not take a haircut after halachic midday. Maran Ha’Chida (in his Moreh Be’Etzbah) and Rabbeinu Chaim Palagi (in his Chaim Le’Rosh) rule likewise. Similarly, Rabbeinu Yosef Haim writes in his Ben Ish Hai that a G-d-fearing individual should act stringently and not take a haircut after halachic midday in accordance with Kabbalah. Rather, one should only do so in the morning.
The Sefer Mishcha De’Rabvata (authored by the Tunisian luminary, Hagaon Harav Masood Alfassi and his sons Rabbi Shlomo and Rabbi Chaim) writes that there is no proof from the words of Rabbeinu Chaim Vital to prohibit haircuts past halachic midday, for the reason why the Ari z”l would abstain from doing so was because there is a disagreement among the Poskim whether one may take a haircut after midday before having prayed Mincha and the Ari would pray Mincha later in the evening, before sunset. It is for this reason that the Ari z”l acted stringently and did not take a haircut in the afternoon and not for any other reason. He therefore rejects the opinion of the Chemdat Yamim and the other Poskim who write that there is a Kabbalistic reason not to do so.
Maran Rabbeinu Ovadia Yosef zt”l proves (in his Responsa Yechave Da’at, Volume 4, Chapter 20) that the Magen Avraham likewise understood the position of the Ari z”l as the Mishcha De’Rabvata did and there is no Kabbalistic issue with taking a haircut in the afternoon. The only reason the Ari abstained is because he did not yet pray Mincha. Many other great Acharonim concur.
Thus, halachically speaking, one need not abstain from taking a haircut during the afternoon or nighttime hours. This is indeed the prevalent custom, as quoted by the Ben Ish Hai.