Butterflies stay in their cocoon, the larval stage, for a varied amount of time. The larval stage can range from 2 weeks for a Monarch butterfly to an entire season for others, which is winter in temperate climates and the dry season in the tropics.
The cocoon is camouflaged so that predators do not see the butterfly while it is in the cocoon; this is during the larval stage. At this time, the pupae becomes the juvenile butterfly that comes out of the cocoon. The insect is not active during this time, which allows the break down of the larva's structure and the building of the butterfly's structure.
When the time is right, the insect comes out of the cocoon. Some of the insects bite their way out, while most of them spit on the ends to soften them and then break their way out. Butterflies usually come out of the cocoons in the morning.