Their formula looks correct. As is usually the case, there are multi ways to derive this result. I will outline two of them here.
Reflection Principle & Measure Change
The solution to the risk-neutral dynamics of $S$ is
\begin{equation}
S_t = S_0 \exp \left\{ \left( r - \frac{1}{2} \sigma^2 \right) t + \sigma W_t^* \right\},
\end{equation}
where $W^*$ is a $\mathbb{P}^*$-Brownian motion. We have $S_t = B$ when
\begin{equation}
W_t^* + \frac{1}{\sigma} \left( r - \frac{1}{2} \sigma^2 \right) t = \frac{1}{\sigma} \ln \left( \frac{B}{S_0} \right).
\end{equation}
Now let
\begin{equation}
\lambda = \frac{1}{\sigma} \left( r - \frac{1}{2} \sigma^2 \right), \qquad \alpha = \frac{1}{\sigma} \ln \left( \frac{B}{S_0} \right)
\end{equation}
and define a new probability measure $\hat{\mathbb{P}}$ equivalent to $\mathbb{P}^*$ through the Radon-Nikodym derivative process
\begin{equation}
\xi_t \left( \mathbb{P}^*, \hat{\mathbb{P}} \right) = \left. \frac{\mathrm{d} \hat{\mathbb{P}}}{\mathrm{d} \mathbb{P}^*} \right| \mathfrak{F}_t = \mathcal{E}_t \left( - \int_0^\cdot \lambda \mathrm{d}W_u^* \right) \qquad \mathbb{P}^*\text{-a.s.},
\end{equation}
where $\mathcal{E}$ is the Doleans-Dade exponential martingale. It follows by Girsanov's theorem that the process $\hat{W}$ defined by
\begin{equation}
\hat{W}_t = W_t^* + \lambda t
\end{equation}
is a standard Brownian motion under $\hat{\mathbb{P}}$. Next, by the reflection principle for Brownian motion, PDF of the first passage time $\nu$ of $\hat{W}$ to a level $\alpha$ is given by
\begin{equation}
\hat{\mathbb{P}} \left\{ \nu \in \mathrm{d}t \right\} = \frac{\vert \alpha \vert}{t \sqrt{2 \pi t}} \exp \left\{ -\frac{\alpha^2}{2 t} \right\} \mathrm{d}t;
\end{equation}
see for example Equation (II.6.3) in Karatzas and Shreve (1991), p. 80 or Theorem 3.7.1. in Shreve (2004), p. 113. I take this result as given and you can find details on its derivation in the references. Using the abstract Bayes rule; see for example Lemma A.1.4 in Musiela and Rutkowski (2005), p. 615, we get
\begin{eqnarray}
\mathbb{P}^* \left\{ \nu \in \mathrm{d}t \right\} & = & \mathbb{E}_{\mathbb{P}^*} \left[ \mathrm{1} \{ \nu \in \mathrm{d}t \} \right]\\
& = & \mathbb{E}_{\hat{\mathbb{P}}} \left[ \xi_t^{-1} \left( \mathbb{P}^*, \hat{\mathbb{P}} \right) \mathrm{1} \{ \nu \in \mathrm{d}t \} \right]\\
& = & \mathbb{E}_{\hat{\mathbb{P}}} \left[ \exp \left\{ \lambda \hat{W}_t - \frac{1}{2} \lambda^2 t \right\} \mathrm{1} \{ \nu \in \mathrm{d}t \} \right].
\end{eqnarray}
Now, when $\nu = t$ then $\hat{W}_t = \alpha$ and thus
\begin{eqnarray}
\mathbb{P}^* \{ \nu \in \mathrm{d}t \} & = & \exp \left\{ \lambda \alpha - \frac{1}{2} \lambda^2 t \right\} \hat{\mathbb{P}} \{ \nu \in \mathrm{d}t \}\\
& = & \frac{\vert \alpha \vert}{t \sqrt{2 \pi t}} \exp \left\{ -\frac{(\alpha - \lambda t)^2}{2 t} \right\} \mathrm{d}t.
\end{eqnarray}
Note that the $\alpha - \lambda t$ term is equal to $Z$ in your reference.
Differentiating the Barrier Option Price
Let $\psi = -1$ ($\psi = +1$) indicate an upper (lower) barrier. Consider a contract with the terminal payoff $V_T = \mathrm{1} \{ \nu > T \}$. Using the method of images, it can be shown that its valuation function in terms of the time-to-maturity $\tau = T - t$ is given by
\begin{equation}
\tilde{V}(S, \tau) = \mathcal{B}_B^\psi(S, \tau) - \mathcal{I} \left\{ \mathcal{B}_B^\psi(S, \tau) \right\},
\end{equation}
where
\begin{eqnarray}
\mathcal{B}_B^\psi & = & e^{-r \tau} \mathcal{N} \left( \psi d_-(S, B) \right),\\
d_-(S, B) & = & \frac{1}{\sigma \sqrt{\tau}} \left( \ln \left( \frac{S}{B} \right) + \left( r - \frac{1}{2} \sigma^2 \right) \tau \right),\\
\mathcal{I} \left\{ \tilde{V}(S, \tau) \right\} & = & \left( \frac{S}{B} \right)^{2 \alpha} \tilde{V} \left( \frac{B^2}{S}, \tau \right)\\
\alpha & = & \frac{1}{2} - \frac{r}{\sigma^2};\\
\end{eqnarray}
see e.g. Buchen (2001) or Wilmott et al. (1995). Note that the option price is linked to the first passage time CDF through
\begin{eqnarray}
\mathbb{P}^* \{ \nu > \tau \} & = & e^{r \tau} \tilde{V}(S, \tau)\\
& = & \int_\tau^\infty \mathbb{P}^* \{ \nu \in \mathrm{d}\tau \}
\end{eqnarray}
and thus
\begin{equation}
\frac{1}{\mathrm{d} \tau} \mathbb{P}^* \{ \nu \in \mathrm{d}\tau \} = -\frac{\partial}{\partial \tau} \left\{ e^{r \tau} \tilde{V}(S, \tau) \right\}.
\end{equation}
Carefully differentiating the two terms in $\tilde{V}(S, \tau)$ yields
\begin{eqnarray}
\frac{\partial}{\partial \tau} e^{r \tau} \mathcal{B}_B^\psi(S, \tau) & = & -\psi \mathcal{N}' \left( \psi d_-(S, B) \right) \frac{1}{2 \sigma \tau \sqrt{\tau}} \left( \ln \left( \frac{S}{B} \right) - \left( r - \frac{1}{2} \sigma^2 \right) \tau \right)
\end{eqnarray}
and
\begin{eqnarray}
\frac{\partial}{\partial \tau} e^{r \tau} \mathcal{I} \left\{ \mathcal{B}_B^\psi(S, \tau) \right\} & = & -\psi \left( \frac{S}{B} \right)^{2 \alpha} \mathcal{N}' \left( \psi d_-(B, S) \right) \frac{1}{2 \sigma \tau \sqrt{\tau}} \left( \ln \left( \frac{B}{S} \right) - \left( r - \frac{1}{2} \sigma^2 \right) \tau \right).
\end{eqnarray}
Through some tedious algebra, we can show that
\begin{eqnarray}
\left( \frac{S}{B} \right)^{2 \alpha} \mathcal{N}' \left( \psi d_-(B, S) \right) & = & \mathcal{N}' \left( \psi d_-(S, B) \right)\\
& = & \mathcal{N}' \left( d_-(S, B) \right).
\end{eqnarray}
Consequently,
\begin{eqnarray}
\frac{1}{\mathrm{d} \tau} \mathbb{P}^* \{ \nu \in \mathrm{d}\tau \} & = & \frac{-\psi \ln (B / S)}{\sigma \tau \sqrt{\tau}} \mathcal{N}' \left( d_-(S, B) \right).
\end{eqnarray}
It is easy to check that this is the same expression that we obtained before.
References
Buchen, Peter W. (2001) "Image Options and the Road to Barriers," Risk Magazine, Vol. 14, No. 9, pp. 127-130
Karatzas, Ioannis and Steven E. Shreve (1991) Brownian Motion and Stochastic Calculus: Springer, 2nd edition.
Musiela, Marek and Marek Rutkowski (2005): Martingale Methods in Financial Modelling: Springer.
Shreve, Steven E. (2004) Stochastic Calculus for Finance II - Continuous Time Models: Springer.
Wilmott, Paul, Sam Howison and Jeff Dewynne (1995) The Mathematics of Financial Derivatives: Cambridge University Press