If you have a Galaxy S-class, two things come to mind:
1. You have "WiFi Power Save" mode enabled. To disable, perform the following steps.
Dial *#0011#
Press menu key
Select WiFi
Middle of display is button for WPSM; If green, press to disable.
It will cycle WiFi to enable.
2. There are many downloadable apps that have the ability to disable wifi between certain hours. Be sure you don't have something like this installed and enabled.
A weak or marginal wifi signal can also cause this.