Midnight is the time when New Year's Eve ends and New Year's Day begins in the ordinary civil calendar.
In everyday timekeeping, midnight marks the boundary between one calendar date and the next. Thus December 31 ends at the instant commonly labeled 12:00 a.m., and January 1 begins. New Year's Eve celebrations count down toward this transition, although local events may continue long afterward.
The word midnight literally refers to the middle of the night, but the exact civil boundary is defined by clocks and calendars rather than by sunrise or sunset. Different time zones reach January 1 at different moments, which is why New Year's celebrations move around the globe over many hours. Daylight-saving rules can affect local clock labels in some places, though they do not change the date boundary itself.
A common source of confusion is the label 12 a.m. Some people prefer saying “12 midnight” or “00:00” because those forms make the date change clearer. In the 24-hour clock, the boundary is written 00:00 at the start of January 1.