Yes! You can I've done this myself. What I'd do is make a consumable item, and add the following to the method when the item is consumed.
First, of all. dayTime yes/no?
Now, when exactly is it daytime or nighttime? Well..Code:dayTime bool Returns true if it's daytime, false if it's nighttime. (Terraria v. 1.1.2)
Code:time double Used in conjuction with Main.dayTime to determine time of day. (Terraria v. 1.1.2) If Main.dayTime == true, Main.time goes from 0.0 (dawn) to 54000.0 (nightfall) and resets. If Main.dayTime == false, Main.time goes from 0.0 (nightfall) to 32400.0 (dawn) and resets. 16200.0 (midnight) is in the middle.
So for example, you could do:
Code:Main.dayTime = false; Main.time = 16200.0;
This should set the world's time at midnight.
Taken from: http://tconfig.wikia.com/wiki/Main_Class
Thanks @Gorateron
And if its no problem im confused on what i should put in a npc.cs (npc name)
Could you help