Exercising earlier in the day is generally better for sleep, as vigorous exercise close to bedtime can make it harder to fall asleep.