Time dilation formula in special relativity I'm confused by the derivation of the expression for time dilation as well as the concept itself.
I've read multiple answers, textbooks, watched lectures, and they confused me further due to subtleties that are not fully explained. Here's what I know tho.
Let $S'$ be an inertial frame moving with velocity $v$ with respect to another frame $S$.
The Lorentz transformation equation of the time coordinate is $$t'=\gamma\Bigl(t-\cfrac{v}{c^2} x\Bigr)$$
So the time interval between two events would be $$\Delta t'=\gamma\Bigl(\Delta t-\cfrac{v}{c^2}\Delta x\Bigr)$$
This is the most general expression for the time difference between two events. If the time in $S$ is taken on one and the same clock, then $\Delta x=0$ and $\Delta t'=\gamma\Delta t$ which means the time difference in the moving frame is greater than in the rest frame.
But $\Delta x$ needn't be zero. Or should it be? Should the time difference in $S$ be taken on the same clock? Why not any two clocks in any two locations $x_1$ and $x_2$? If all the clocks in $S$ are synchronized, it shouldn't matter, right?
If that's right, however, then if the two events under consideration are the moving observer coinciding with point $x_1$ at time $t_1$ and $x_2$ at time $t_2$, then we can write $\Delta x=v\Delta t$ and that would give us $\Delta t'= \Delta t/\gamma$ which says that the time on the moving clock is less than on the stationary one. Is this in agreement with the case of $\Delta x=0\,$?
Also, $\Delta x$ doesn't have to be either of the previous cases. Can't we talk about events far away from where the observers are located such that $\Delta x$ is neither of the two cases?
Finally, what does it mean for a clock to run slower? Does it mean that, say, the hands are moving slower, in which case it would measure less time difference between events? Or does it mean that the time difference between two events is greater on the said slower clock which gives the name "time dilation"?
 A: (a) I find talk of 'moving clocks' and 'stationary clocks' confusing. I recommend this definition of time dilation:
The time interval between two events is least in the inertial frame in which the events occur at the same place (strictly: with the same spatial co-ordinates). In any other inertial frame the events occur in different places and the time interval between them is greater by a factor of $\gamma(v)=(1-v^2/c^2)^{-1/2}$ in which $v$ is the relative velocity between the frames. [In Special Relativity we may call the shortest time 'the proper time' and the longer times 'improper times'.]
In your question you start by having the events occurring at the same place in the S frame. $\Delta t$ is therefore the proper time between the events. You have argued correctly that in the S' frame the time $\Delta t'$ between the events is longer by a factor of $\gamma(v)$.
(b) You then go on to ask: "Should the time difference in S be taken on the same clock? Why not any two clocks in any two locations 1 and 2 ? If all the clocks in S are synchronized, it shouldn't matter, right?"
The point about the S frame is that it is special for the two events, because they take place with the same spatial co-ordinates in this frame, so you need only one clock, at the place where both events occur. I suppose that you could use clocks elsewhere in S, but you'd have to allow for transit times of signals sent from the point at which the events occur to the clocks that you are using! But $\Delta x$ is still zero, because $\Delta x$ is the distance between the points at which the events themselves occur!
(c) "what does it mean for a clock to run slower?" It means that it registers a shorter time between the same two events.
I dislike this form of words in Special Relativity. It makes it seem as if the clock's mechanism has been affected, whereas time dilation is due to the interconnectedness of time and space.
A: 
If the time in S is taken on one and the same clock, then Δx=0 and
Δt′=γΔt which means the time difference in the moving frame is greater
than in the rest frame.

I like the mantra: "moving clocks run slowly" to avoid becoming in doubt in SR.
The meaning of $\Delta x = 0$ is that S' compares the time interval shown by its clock with a clock on a given $x$ in S frame. In this case, we can invert the perspective and see that from the static (in his frame) clock of S', time runs slowly in a given location of S. That is the usual concept we have of clocks in SR: they run slowly in a moving frame.
But as you say, $\Delta x$ can be non zero. For example S' can compare the readings of its clock with a clock in S on $x = 0$ and later on with a syncronized (in the S frame) clock on $x = \Delta x = v\Delta t$. In this case: $$\Delta t' = \gamma(\Delta t - v^2 \Delta t) \implies \Delta t' = \frac{\Delta t}{\gamma}$$
Now, S' is not following the readings of the same moving clock. It compares the readings of 2 clocks in S. Its is reasonable now to call S' the moving frame. The conclusion is the same: the moving clock runs slower.
Of course S' can say that S is moving and one of the clocks is receding while the other is approaching. But it is like going from Earth to Alpha Centaury, and compare with a clock here and the other there. It is easier to call this a trip from here to the star, and not that the star comes to the ship, while the earth goes away.
A: 
But Δx needn't be zero. Or should it be? Should the time difference in S be taken on the same clock? Why not any two clocks in any two locations x1 and x2?

The time difference that is measured on a clock at the same location is called the proper time. This will be the smallest measured time difference of any observer.
If you choose to assume that $\Delta x = 0$ (or rather, you choose to considerer two events A and B at the same location in S) then in the S frame the clock measuring the time between the events is stationary (i.e., the events occur at the same location in S) and $\Delta t$ is the proper time.
This time $\Delta t$ will be less than that measured by a moving observer. But, don't forget that in this case the moving observer is in the S' frame and is moving at velocity $v$ as measured in the S frame.
In this case, indeed you will have $\Delta t' = \gamma \Delta t$, such that $\Delta t'$ is bigger than $\Delta t$.
However, note that the location of the moving observer in the S' frame in this case can not be the same as the location of the measured events we are discussing above, since the observer is moving in this frame and the measured event is at the same location in this frame.


however... which says that the time on the moving clock is less than on the stationary one.

If you want to consider the moving observer to be measuring the proper time interval between events, you can do that too, but in this case you will not have $\Delta x = 0$ and $\Delta t$ will not be the proper time. Now $\Delta t$ and $\Delta x$ are referring to the difference between different events than the events discussed above. The events will necessarily be different than the events discussed above. We should probably use labels like $\Delta t_{A,B}$ and $\Delta t_{C,D}$ to differentiate between the time difference between events A  and B (the ones considered above) and the time difference between events C and D (the ones considered here). We usually don't do all this extra labeling though.
For example, if the S frame is fixed on earth and the S' frame is in a spaceship moving away from earth, then if we consider measurements of events C and D that occur at the same location in the spaceship, then $\Delta x'=0$ and it is $\Delta t'$ that is the proper time not $\Delta t$.
In this case, indeed, you will have $\Delta t = \Delta t' \gamma$ such that $\Delta t$ is bigger than $\Delta t'$.

This could seem quite confusing if we don't include the extra labels, but with the extra labels is it probably more clear:
$$
\Delta t'_{A,B} = \gamma \Delta t_{A,B}
$$
$$
\Delta t_{C,D} = \gamma \Delta t'_{C,D}
$$
The events A and B are measured at the same location in frame S. The events C and D are measured at the same location in frame S'.

Update based on comments:
There is no reason why either the observer in S or the observer in S' necessarily has to measure the proper time. Indeed, the events could be spatially seperated in both frames. In this case just fall back to the general Lorenz transformation equations for the differences:
$$
c\Delta t' = \gamma c\Delta t - \beta \gamma \Delta x 
$$
$$
\Delta x' = -\beta\gamma c\Delta t + \gamma \Delta x\;.
$$
For example, suppose that the relative velocity between S and S' is v = 200m/s and the origins coincide at time zero. And suppose further that, in S, event E is at time $t_E= 0$ seconds and location $x_E = 0$ meters and event F is at time $t_F = 1$ second and location $x_F = 100$ meters. These events can also be seen to be spatially separated in S' and neither S or S' measures the proper time.
In S' Event E also occurs at $t'_E=0$ and $x'_E=0$ and we have
$$
ct'_F = \gamma c t_f - \beta \gamma x_F = \gamma c 1s - \beta \gamma 100m
$$
and
$$
x'_F = \gamma x_f - \beta \gamma c t_F = \gamma 100m - \beta \gamma c 1s
$$
Or
$$
t'_F = \gamma (1 - \frac{200}{300000000} 100/300000000) = \gamma (1 - \frac{1}{4500000000000})\quad \text{seconds}
$$
and
$$
x'_F = -\gamma 100 \quad \text{meters}\;,
$$
where I have approximated $c = 300000000m/s$ and where, in this case, $\gamma$ is approximately 1.0000000000002.
A: Time dilation does not mean that clocks slow down when they move- that is a common misconception.
Time dilation arises from the relativity of simultaneity, which is responsible for length contraction also.
The effect is simplest to explain in the case of a 2-d spacetime. In a given reference frame, lines parallel to the x-axis are lines of constant time- anywhere along such a line it is the same time t. However, when two frames move relative to each other, their time axes tilt relative to one another, so what constitutes a level line of constant time in one frame is a sloping slice through time in the other, the slope rising upwards in the direction of motion. That means a constant time t in one frame is a successively later time in the other as you move further away from the origin.
By analogy, imagine walking down a corridor at 1m/s in which there was a person holding a clock every ten metres, but those clocks are all set 1 second ahead of each other. After walking 10m you reach the first person- 10 seconds have passed on your watch, but the person's clock shows 11 seconds have passed, because it has been set 1s ahead. You walk another 10m to reach the next person- 20s are shown to have passed on your watch, but their clock shows 22s, because it was 2s ahead. As you go further and further down the corridor, time on the clocks gets increasingly ahead of the time on your watch. By the time you have walked 200m, 200 seconds have passed on your watch, but the adjacent person's clock shows 220 seconds. Compared with the clocks of the people you are passing, your watch appears to be time dilated- it is not because your watch is running slower than their clocks, but because you are moving into regions of increasingly later time in the corridor frame. Your watch and all the clocks are all running at exactly the same rate, but your watch seems time dilated because the clocks are progressively out of synch in your frame.
Now, suppose that following you down the corridor at 10m intervals are other people wearing watches, and their watches are each set a second ahead of each other. From the perspective of any of the people holding a clock, they pass successive walkers with watches, and when they compare their clock with the passing watches  they see that their clock seems to be running slow, because the time it shows is increasingly behind the time on the passing watches.
So, the effect is entirely symmetrical. From the perspective of any person with a watch, their watch seems to be time dilated according to the clocks they are passing in one direction, and from the perspective of any person with a clock, their clock seems to be time dilated compared with the watches they are passing in the other direction, and yet all the clocks and watches are running at exactly the same rate.
So you should be able to see that time dilation is an effect that arises not as a result of clocks slowing down but as a consequence of the relativity of simultaneity, which means that clocks in one frame are progressively more out of synch with clocks in another the further you move away from the origin.
Another thought experiment to help you convince yourself that clocks do not slow down when they move, is to remember that speed is entirely relative. You do not have a fixed speed as you sit at your computer reading this- you simultaneously have all possible speeds relative to all possible reference frames. There are frames of reference in which your heart beats only once a year, frames in which it beats once a month, frames in which it beats once a day and so on. Clearly your heart continues to beat at the same rate in your rest frame.
As for your question about Δ being 0, that simply refers to a case in which the elapsed time at a single point in one frame is compared to the time difference between two corresponding points in a moving frame. In that case, the formula for the Lorenz transform takes the simplest form, but there is nothing else special about it. You are free to consider other cases in which Δx is not zero, in which case you will get a different factor when you transform the elapsed time from one frame to another.
A: The answers from Marco Ocram and Phillip Wood look good to me but I think some basic definitions might help demystify time.
Clocks

*

*Time is what a clock measures.


*A clock is a system that repeats a particular process over and over
and counts the iterations.


*Two clocks are identical if they repeat the same process.


*Any repeatable process is a clock if something is there to count it.
The universe is such that, for any given inertial reference frame, the average number of iterations of a specific repeating process (such as a clock might count) that transpire between the start and end of another specific process is identical. That is: one characteristic of any specific process is its most likely duration, expressible as a number $n$ of iterations on a sufficiently precise clock in the same inertial reference frame.
It doesn't mean much to ask how fast or slow a clock is running. Speed implies a rate of change with respect to time. A clock measures time, and the rate of change of time with respect to time is always dimensionless $1$. The clock runs at one count per iteration of its process, which has a fixed ratio (with slight statistical variation) to all iterations of all other processes.
Time Dilation
The universe is such that when a clock in some inertial reference frame has counted $n$ iterations of its repeating process, an identical clock with a fixed relative velocity $v$ will have counted $n/\gamma (v)$ iterations, as measured by the same frame that measured $v$.
That is to say, in any given inertial reference frame A,

*

*Processes in all other inertial reference frames evolve, with respect to a clock in frame A, at a slower rate than an identical process in frame A would evolve with respect to a clock in frame A.


*Processes in all other inertial reference frames evolve, with respect to a clock in their own reference frame, at the same rate an identical process in frame A would evolve with respect to a clock in frame A.
A: "Consider a simple light clock in its rest frame. The clock consists of two parallel mirrors with a photon bouncing between them. The photon’s period of oscillation in its rest frame is
(1) $T = 2d/c$.
As usual $c$ is the speed of light and $d$ stands for the “proper” distance between the parallel mirrors.
Now let us consider the period of this clock as measured by Observers A and B, each moving with speed $v$ toward the clock. Each of the two observers carries along a clock identical to the mirror clock for time keeping. Observer A will see the clock moving toward her with velocity $v$ and measures the period of the moving clock as the time taken by the photon to bounce up and down between the two mirrors. Let $T_{A}$ be the period of the clock measured by Observer A. Clearly $T_{A}$ is the time the photon takes for a round trip between the two mirrors, which consists of one bounce up and one down. The length of each bounce $D$ is simply the hypotenuse of a right triangle with the sides $d$ and $vT_{A}/2$. Therefore,
(2) $D = [d^2 + (vT_{A}/2)^2]^{1/2}$,
and the round trip time is given by
(3) $T_{A} = 2D/c = \{2[d^2 + (vT_{A}/2)^2]^{1/2}\}/c$
or
(4) $T_{A}^2 (1 – v^2/c^2) = 4d^2 /c^2$
since by Eq. (1)
(5) $4d^2 /c^2 = T^{2}$.
Observer A concludes that the period of the moving clock is
(6) $T_{A} = T / (1 – v^2/c^2)^{1/2}$
This is the usual time dilation result. So Observer A concludes that the “moving” clock runs slow compared with his own clock." (Fred Behroozi).
Where equation (6) gives is the equation used in Relative Velocity Time Dilation:
change in $t'$/change in $t = 1/(1-v^{2}/c^{2})^{1/2}$  OR
$t = t_{0}/(1-v^{2}/c^{2})^{1/2}$
where: $t =$ time observed in the other reference frame
$t_{0} =$ time in observers own frame of reference (rest time)
$v =$ the speed of the moving object
$c =$ the speed of light in a vacuum
Hope it helps!
