What's the meaning of “within x of something”?

What's the meaning of " A is 2 hours within of B " ? Is it correct? "A-B=2 hours or B-A=2 hours" . Assume A: my estimate distance from home to the bus station and B: the actual distance from my home to the bus station

Your statement A is 2 hours within of B is ungrammatical. It should be

A is within 2 hours of B.

It means that it would require two hours or less to travel from A to B.

As already pointed out, the phrase is:

(something) is (amount) within [of (something else)].

• My office is within 2 miles of the bus station.

• The second train departs within 5 minutes of the first train's arrival.

It is common to drop the last part. In that case, you would normally understand it to mean "now" for time, "here" for space, and so on:

• My office is within 2 miles.

== My office is within 2 miles of here.

• The train departs within 5 minutes.

== The train departs within 5 minutes of now.

For points within a perimeter, of is not used:

• These trees are within my property.

• The jar is within my reach.

"A-B=2 hours or B-A=2 hours"

Mathematically, you could think of within as expressing < (less than) or ≤ (less than or equal to), depending on the situation. Or informally ± (plus or minus).

• The point x is within the circle C.

In this situation I would assume you mean strictly less than. I.e. if the point lies exactly on the border of the circle, it is no longer considered to be 'within' the circle:

Let d_x be the distance from the center of circle C to point x.

Let r be the radius of C.

d_x < r

• My house is within 2 miles of the train station.

In this situation I would assume mean less than or equal to (≤) rather than strictly less than (<). In other words, if your house is actually exactly 2.000 miles from the train station, you have still made an accurate statement.

• The estimate is within 5%.

== The estimated value is within 5% of the true value.

In this situation, I would suspect you mean that the estimate could be less than 5% of the true value, or it could be exactly 5% of the true value. I.e. ≤ (less than or equal).

Let e be the estimated value.

Let v be the true value.

v - 0.05v ≤ e ≤ v + 0.05v