The Shulchan Aruch · Orach Chayim
אורח חיים ל׳Orach Chayim 30
Siman 30 of 697 in Orach Chayim — 5 se'ifim
הלכות תפיליןLaws of Tefillin· siman 30
Se’if 1א׳
זְמַן הֲנָחָתָן בַּבֹּקֶר, מִשֶּׁיִּרְאֶה אֶת חֲבֵרוֹ הָרָגִיל עִמּוֹ קְצָת בְּרִחוּק אַרְבַּע אַמּוֹת וְיַכִּירֶנּוּ.
The time to put them [Tefillin] in the morning is at the time when one can see his close friend from four cubits away and recognize him.
Se’if 2ב׳
אָסוּר לְהָנִיחַ תְּפִלִּין בַּלַּיְלָה, שֶׁמָּא יִשְׁכְּחֵם וְיִישַׁן בָּהֶם. אִם הֵנִיחָם קֹדֶם שֶׁתִּשְׁקַע הַחַמָּה וְחָשְׁכָה עָלָיו, אֲפִלּוּ הֵם עָלָיו כָּל הַלַּיְלָה, מֻתָּר, וְאֵין מוֹרִין כֵּן. אִם לֹא חָלַץ תְּפִלִּין מִשֶּׁשָּׁקְעָה חַמָּה מִפְּנֵי שֶׁלֹּא הָיָה מָקוֹם לְשָׁמְרָן, וְנִמְצְאוּ עָלָיו כְּדֵי לְשָׁמְרָן, מֻתָּר, וּמוֹרִין כֵּן.
One is prohibited to put Tefillin on at night since he may forget [that he has them on] and sleep in them. If he puts them on before the sun sets and it happens to get dark, even if he wears them the whole night, it is permitted. [However] we do not teach [people] to do this. If he did not remove the Tefillin once the sun set since he had no place to guard them and therefore, left them on to protect them... This is allowed and is such taught.
Se’if 3ג׳
הָיָה רוֹצֶה לָצֵאת לַדֶּרֶךְ בַּהַשְׁכָּמָה מְנִיחָם, וּכְשֶׁיַּגִּיעַ זְמַנָּם יְמַשְׁמֵשׁ בָּהֶם וִיבָרֵךְ, דְּלֵיכָּא לְמֵיחַשׁ שֶׁמָּא יִישַׁן בָּהֶם, כֵּיוָן שֶׁהִשְׁכִּים וְיָצָא לַדֶּרֶךְ.
If one wanted to go out on his way early [in the morning, before the actual time that is permitted to put them on], he puts them on, and when their time comes ,he should feel them and make the bracha on them. There is no need to be concerned that he may sleep in them since he is getting up to go on his way.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0