Portuguese is more or less coherent in the use of prepositions in relationship to time specifications, see 20.1.4.1. In English it is a bit more confusing. Different prepositions are use and sometimes no preposition at all.
He comes at five o'clock.
At sunrise the cock crows, only the birds chirp.
In the afternoon I have time.
At the same time a car came around the corner.
On holidays we do what we want.
In Portuguese it is much simpler. It is always a or a and article (à, às, o, aos).
a in relationship to specifications of time
Gosto de estar na praia ao pôr-do-sol.
I like to be on the beach at sunset.
Quem não foi socialista aos vinte anos não tem coração; quem continua sendo aos quarenta não tem cérebro.
Those who were not socialist at the age of twenty have no heart. Who is still a socialist at the age of fourty doesn't have a brain.
Saíamos cedo e retornávamos já próximo ao anoitecer.
We left early and came back when it was dawning.
Ao começar a Guerra Civil Espanhola, se alistou no bando republicano.
At the outbreak of the Spanish civil war he fought on the side of the republic.
Although there are some exceptions.
É hora de dizer a verdade.
It is time to tell the truth.
The time is indicated without preposition and in opposite to Spanish and Italian without article as well.
São três horas da manhã.
It is three o' clock in the morning.
(Not "Son las tres de la mañana" as in Spanish and not "Sono le tre di mattina" as in Italian. Very often Portuguese is nearer to French then to Spanish, what is astonishing. In French there is no article neither: "Il est trois heures du matin".)
Obviously the preposition a is not used either in case that more complex relationships are to be described.
A partir do nascer do sol iniciava-se o dia que durava até o por do sol.
The day started with the sunraise and ended with the sunset.