Short answer
Most scholars place the Buddha’s lifetime roughly in the 5th to 4th century BCE, though exact dates are debated. The Krishna most people have in mind, the figure in the Mahabharata and the Bhagavad Gita, is generally dated later. Many scholars place the Bhagavad Gita somewhere between about the 2nd century BCE and the 2nd century CE. On that reading, the Buddha came first.
Why the answer is not simple
Several things complicate the question.
- The name Krishna appears in some early Upanishads, which may be older than the Buddha. Whether that Krishna is the same figure as the later hero of the Gita is debated.
- The Mahabharata grew over many centuries, so its date is better described as a range than as one moment. Because the Gita is part of the Mahabharata, its date is uncertain in the same way.
- The Buddha and Krishna became part of different religious traditions, and each tradition has its own account of their history. Later Hindu texts count the Buddha among the avatars of Vishnu. That is a development that came well after the Buddha’s time, not an early one.
What this means in practice
If you ask which figure is older in the historical record, the Buddha is usually placed first. If you ask which name appears earlier in any text, the answer is less clear, because Krishna’s name appears in older Upanishads. Both answers depend on which figure and which text you have in mind.
For a related question about how Vishnu fits into the story, see Is Vishnu Mentioned in Buddhism?