How to turn of My wireless remotely my command

I have a wireless router that I need to switch off once in the night and switch on later, I had this idea of building up something like magic packets that would automatically put the device off when not in use or late hours. How can this be achieved? Which would be the best interface to achieve this between the Html and java?
