The distance to Mars varies between the planet's closest approach to Earth at 35 million miles and the farthest distance at 140 million miles. In theory, it would take the fastest spacecraft ever built 39 days to reach Mars at its closest distance and 289 days at its most distant.
The fastest spacecraft ever built is the New Horizons probe, which has an average speed of 36,000 mph. The average amount of time it would take to reach Mars is 162 days, but the reality is different because the craft cannot pass through the sun. Accurate times require knowledge of fuel requirements and complex gravitational equations.