How do pilots manage their flight times?
Airlines are required to have extra pilots on long flights so that pilots can take rest breaks.
A typical 18 hour flight from New York to Singapore will have four pilots. The pilots will divide the rest breaks so that there is always two pilots in the flight deck at the controls, and two pilots in a crew rest facility. Most crew rest areas will have beds or bunks to sleep in.
Typically all four pilots are in the flight deck from takeoff to about 10,000' and then again from 10,000' to landing. The cruise portion of the flight be divided so that each pilot gets an equal amount of rest. Various airlines will differ on how this is done.
Usually two pilots will be paired to take the same rest breaks so that they don't disturb anyone when they enter or leave the crew rest area. For example many airlines will divide a 16 hour cruise portion of the flight so that the paired pilots each get two 4 hour breaks. Some airlines will divide the time so that there is one 8 hour rest period instead of two 4 hours rest periods.