You can do a spell a any time yes not just midnight
But a spell can work best on a time that matches it's meaning
Like when a moon is waxing full ect... Would be the best time
Workings can be done from the day of the new moon to three-and-a-half days after. The new moon is for starting new ventures, new beginnings. Also love and romance, health or job hunting.
From seven to fourteen days after the new moon.The waxing moon is for constructive magic, such as love, wealth, success, courage, friendship, luck and health.
From fourteen to seventeen-and-a-half days after the new moon. Prime time for rituals for prophecy, protection, divination. Any working that needs extra power, such as help finding a new job or healing for serious conditions, can be done now. Also, love, knowledge, legal undertakings, money and dreams.
From three-and-a-half to ten-and-a-half days after the full moon.The waning moon is used for banishing magic, for ridding oneself of addictions, illness or negativity.
From ten-and-a-half to fourteen days after the full moon. The dark moon is a time for ridding oneself of bad habits, Binding spells, for exploring our darkest recesses and understanding our angers and passions. Also bringing justice to bear.
But you can do these spells a any time during that moon period
I made this from the best of my knowledge if there are any corrections please post