In more detail
Sunrise and sunset are defined for the top edge of the Sun, and the atmosphere bends light over the horizon, so the Sun's centre is about 0.833° below the horizon at those moments. Day length then follows from cos ω = (sin(−0.833°) − sin φ × sin δ) / (cos φ × cos δ), where φ is latitude, δ is the Sun's declination (+23.44° at the June solstice, −23.44° in December) and day length is 2ω / 15 hours. Clock times also depend on where you are within your time zone, the equation of time (up to about 16 minutes) and daylight saving time. Twilight lasts until the Sun is 6° (civil), 12° (nautical) or 18° (astronomical) below the horizon.
Why it matters
Because of refraction, days at the equinox and at the equator are a few minutes longer than 12 hours. Beyond the polar circles the Sun can stay up or down all day. Hills, buildings and your own elevation shift the times you actually see, so published times are for a flat horizon.
Example
Day length from the formula above (sea level, flat horizon):
Latitude June solstice Equinox December solstice
0° 12 h 07 min 12 h 07 12 h 07
40.7° N 15 h 06 min 12 h 09 9 h 15
51.5° N 16 h 38 min 12 h 11 7 h 50
60° N 18 h 52 min 12 h 13 5 h 52
Common confusion
Hours of daylight are not the same as Peak sun hours, the measure used for solar panels.