How to do calculation in relativity of simultaneity
The only safe way for beginners to answer questions in special relativity is to sit down with a large sheet of paper and work through the Lorentz tranformations:
$$\begin{align} t' &= \gamma (t - \frac{vx}{c^2}) \\ x' &= \gamma (x - vt) \end{align}$$
Let's be absolutely clear what the tranformations tell us. If we use a coordinate system $(t, x)$ to label spacetime points, and another observer moving at constant velocity $v$ relative to us uses another coordinate system $(t', x')$, the transformations convert our labels $(t, x)$ to the other observer's labels $(t' x')$.
So to answer your question we take the two spacetime points labelling the ends of the train and apply the transformations. This tells us where those two points are in the moving observer's coordinates.
In our frame at $t = 0$ the middle of train is at $(0, 0)$, so the front of the train is at $(0, d/2)$ and the rear of the train is at $(0, -d/2)$ (I've called the length of the train $d$ to avoid confusion with the $x$ coordinate):
To find the potition of the front of the train in the primed frame we just feed $t = 0$ and $x = d/2$ into the Lorentz transformations:
$$\begin{align} t' &= \gamma (- \frac{vd}{2c^2}) \\ x' &= \gamma \frac{d}{2} \end{align}$$
So in the moving frame the lightning strike at front of the train is at $(-\gamma\tfrac{vd}{2c^2}, \gamma\tfrac{d}{2})$. I won't go through the details, but same calculation puts the lightning strike at the end of the train is at $(\gamma\tfrac{vd}{2c^2}, -\gamma\tfrac{d}{2})$.
So the answer is that the observer on the train sees the lightning strike the front of the train at $t' = -\gamma\tfrac{vd}{2c^2}$ and the rear of the train at $t' = \gamma\tfrac{vd}{2c^2}$. The time between the lightning strikes is $\gamma\tfrac{vd}{c^2}$.
Quick footnote
Rereading my answer it's just occurred to me that I've called the length of the train $d$ in the rest frame of the track. The length of the train for the observers on it will be greater - you can use the Lorentz transformations to calculate this too.
Length of the train
Re Graviton's comment, the easiest way to calculate the length of the train in the train's rest frame is to work backwards. Let's call the length of the train in its rest frame $\ell$, and we'll choose our zero time so that the rear of the train is at $(0, 0)$ and the front is at $(0, \ell)$. To transform from the train frame to the track frame we just use the Lorentz transformations as before, but in this case the velocity is $-v$ because if the train is moving at $v$ wrt to the track then the track is moving at $-v$ wrt the train.
When we do the transformation $(0, 0)$ just goes to $(0, 0)$ so we just need to work out where $(0, \ell)$ is in the track frame. Plugging in $t = 0$ and $x = \ell$ we find the point in the track frame is:
$$\begin{align} t &= \gamma (t' - \frac{(-v)x'}{c^2}) = \gamma\frac{v\ell}{c^2} \\ x &= \gamma (x' - (-v)t) = \gamma\ell \end{align}$$
So in the track frame the front of the train is at $(\gamma\tfrac{v\ell}{c^2}, \gamma\ell)$. But we don't want to know where the front of the train is at time $t = \gamma\tfrac{v\ell}{c^2}$, we want to know where is was at $t = 0$. So we take our value for $x$ at time $\gamma\frac{v\ell}{c^2}$ and subtract off the distance moved in time $\gamma\frac{v\ell}{c^2}$, which is just the time multiplied by the velocity. This gives us the value for $x_0$:
$$ x_0 = \gamma\ell - \gamma\frac{v\ell}{c^2} v $$
The rest is just algebra. We write the expression out in full to get:
$$\begin{align} x_0 &= \ell \left( \frac{1 - \frac{v^2}{c^2}} {\sqrt{1 - \frac{v^2}{c^2}}} \right) \\ &= \ell \sqrt{1 - \frac{v^2}{c^2}} \\ &= \frac{\ell}{\gamma} \end{align}$$
And since the rear of the train is at $x = 0$ at time zero and the front of the train is at $x = x_0$ at time zero the length of the train is just $x_0$ so:
$$ d = \frac{\ell}{\gamma} $$
At all speeds $> 0$ the value of $\gamma > 1$, so the length of the train as observed from the track is less than the length of the train in its rest frame i.e. the train is shortened. This is the Lorentz contraction.
$\def\cA{{\cal A}} \def\cB{{\cal B}} \def\cM{{\cal M}} \def\RA{{\rm R_\cA}} \def\RB{{\rm R_\cB}} \def\rE{{\rm E}} \def\rF{{\rm F}}$ I have retrieved two drawings I did years ago for a lecture on this topic. I wish to show them in order to illustrate the way of reasoning I find best suited to introductory relativity teaching. There are two figures, showing the same physical situation as it would appear from two reference frames: frame $\tt T$ (the train) and $\tt S$ (the station).
Of course in frame $\tt T$ the train is stationary. In figure $\tt T$ you can see cartesian axes $(x,t)$ I will never use. They are there only to remind that from one frame to the other spacetime coordinates do change. There are three vertical lines, marked $\cA$, $\cB$, $\cM$. These are what I call objects: $\cA$ is the train's head, $\cB$ its tail, $\cM$ its mid-point. Since train is still, $x$-coordinates of these objects do not change with time. Therefore their worldlines have $x=\rm const.$ and are parallel to $t$-axis.
Continuing to examine the figure we see 4 points with their marks. There is one more than would suffice for Einstein's description of relativity of simultaneity, but this will help our analysis. Einstein's idea is to consider two lightnings, simultaneously falling at the train's extremities. In figure these are two events named $\RA$, $\RB$ (why R? I'll explain presently). That these events are simultaneous in $\tt T$ is shown by line $\RA\RB$ being parallel to the $x$-axis.
Note: I chose scales on $(x,t)$ axes so that 1 second in time has the same length as 1 light-second in space. In other words, I use units where $c=1$. Then worldlines of light signals are inclined 45$^\circ$ to the right or to the left.
But to physically ensure simultaneity, I do without lightnings and introduce two flashes starting from mid-point (event $\rE$). Events $\RA$, $\RB$ are defined as the arrivals of these flashes to $\cA$, $\cB$. Simultaneity is guaranteed by $\cM$ being the mid-point and by known assumptions about propagation of light. Flashes are reflected in $\RA$, $\RB$ and come back simultaneously to $\cM$ (event $\rF$).
Another thing to be noted in the figure is the red diamond. It depicts flashes' paths, from $\cM$ (mid-train) to head and tail, and vice versa. The only reason to draw it is to compare with its appearance in frame $\tt S$.
Let's now go to the next figure. It is drawn in frame $\tt S$, where the train is moving to the right, its speed being a fraction of $c$. But not too small a fraction (a relativistic train!) so as to make relativistic effects clearly visible. Axes are named $(x',t')$ since the same event has generally different coordinates in both frames.
Worldlines of $\cA$, $\cB$, $\cM$ are still parallel straight lines (all objects, as parts of the same train have the same constant speed) and are leaning to the right. The $\cM$-line is halfway between the others, as $\cM$ remains equidistant from $\cA$ and $\cB$, even if the train is moving. (Nothing will be said about their distances: Lorentz contraction is present, but we do not need to know this, nor to know its amount.)
But something new is happening: line $\RA\RB$ is no longer parallel to $x$-axis. Let's see why. Follow the flashes emitted in $\rE$. Their worldlines are still at 45$^\circ$, since speed of light is invariant: it is the same in $\tt S$ as in $\tt T$, irrespective of whether its source is still or is moving. It's obvious that the flash aimed at the train's head will employ more time to reach its target than the other one, aimed at the tail. This is because the train's head runs away, whereas the tail goes meet the incoming light. (Note that this has nothing to do with relativity, once you accept that light has the same speed in both directions.) The same result can be arrived at by pure geometry, simply looking at the figure.
We are thus led to an inescapable conclusion: events $\RA$, $\RB$, which were simultaneous in $\tt T$, are not simultaneous in $\tt S$. More precisely, $\RB$ precedes $\RA$. Actually geometry tells something more, if we complete the flashes paths. Their meeting on $\cM$ is an event, and as such cannot change according the frame we use for our measurements. In words, the times of arrival of both flashes in $\cM$ stay always the same, i.e. the red figure is a closed polygon. Its sides are at 45$^\circ$, then the polygon is a rectangle (no longer a diamond, i.e. a square). This ensures us that diagonal $\RA\RB$ makes with $x$-axis the same angle as $\rE\rF$ makes with $t$-axis. (Going on, we could compute the delay of $\RA$ wrt $\RB$.)
Up to now I assumed light source were standing on the train, as well as mirrors reflecting the flashes. What about the opposite situation, when source and mirrors stand still on station's platform?
You have only to interchange roles between $\tt S$ and $\tt T$ i.e. exchange the figure labels, with no change in events names. To be precise, if train goes right wrt station, the station goes left wrt train. Then the slanted lines $\cA$, $\cB$,$\cM$ in the second figure should slant in the opposite direction. As a consequence, events $\RA$, $\RB$, now simultaneous in $\tt S$, aren't so in $\tt T$: $\RA$ precedes $\RB$. And that's all.
If we want to get some intuition about the notion of simultaneity behind this scenario, we can think about it like this.
To avoid any confusion in my discussion, any non-primed letter should indicate a coordinate in the ground observer's reference frame and any primed letter should indicate a coordinate in the moving observer's reference frame.
For the purpose of easy drawing, the train is drawn much smaller than $x$, the distance between $A$ and $B$. Suppose, at time $t=t_{0}$, two lighting strikes at $A$ and $B$, and in the moving observer's frame at $A'$ and $B'$. At that time, the positions of the two observers ($O$ and $O'$) coincide in both of their reference frames. Now, as the observer is moving with speed $v$ in $A$-to-$B$ direction, the points $A'$, $B'$ and $O'$ will be moving along with the observer's frame. Now, lights from $A$ and $B$ will take some time to reach $O$ and in the meantime the moving observer would have moved some distance from $O$. That's why light from $B$ will reach him first, at $t=t_{1}$ even before reaching the ground observer. After some time, the lights from $A$ and $B$ will meet at $O$ where the ground observer is standing (not shown in the drawing). As lights from $A$ and $B$ reach the ground observer at the same time crossing the same amount of distance, the ground observer will conclude the lightnings to be simultaneous.
Now, after some more time, at $t=t_{2}$, light from $A$ would reach the moving observer. At this time, light from $B$ would have crossed the ground observer to reach some point between $O$ and $A$. The moving observer would think that lightnings stroke at points $A'$ and $B'$ in his reference frame, because during the lightnings, those points coincided with $A$ and $B$ respectively. If the ground observer were using pre-relativity physics, then s/he would have thought that the moving observer is measuring the speed of light as $c-v$(from $A$) and $c+v$(from $B$). In that case, the moving observer should have also concluded the lightnings to be simultaneous. However, in special relativity, any inertial observer will measure the speed of light to be $c$. So for the moving observer, s/he is seeing that light from point $B'$ reached him/her first and light from $A'$ reached him/her after some more time. As points $A'$ and $B'$ are moving with the moving observer, those points are still at equal distances from him/her. Therefore, s/he will conclude that lightnings stroke first at $B'$ and then at $A'$.
Now, if we want to know the time difference the moving observer would measure between the lightnings or various distances/lengths involved in this scenario, we have to use Lorentz transformation, just as exactly as Jonh Rennie did.