When force varies, you need to integrate force over displacement to get the total work done: $$ W=\int _{a}^{b}\mathbf {F(s)} \cdot d\mathbf {s}\tag 1 $$
For example. Let's say we need to find a work done, when we compress a spring from $0$ to a final position $\ell$.
Spring force needed to compress to $x$, by Hooke's law, is $$ F(x)=kx \tag 2$$
Now substitute (2) into (1) : $$ \begin{align} W &= \int_0^\ell F(x)dx \\ &= \int_0^\ell kx~dx \\ &=\frac {k~\ell^{~2}}{2} \end{align} \tag 3 $$
After integration, notion of a force at a specific point $F(x)$ in spring, is lost. We are left only with total displacement $\ell$, hence final formula of total work done doesn't care about specific application of force at particular $x \in [0,\ell]$ path point (or at particular time moment). This temporal/spatial information is lost.
You can say to some sense, that varied force is averaged over the entire path by integration procedure. Actually, if you'll equate (3) to a work done by an average force:
$$ \frac {k~\ell^{~2}}{2} = \overline F ~\ell \tag 4,$$
you can extrapolate what is this average force in spring compression $ 0 \to \ell$ :
$$ \overline F = k~ \frac {\ell}{2} \tag 5 .$$
So, for getting total work done, you can either:
integrate varied force over displacement or time, if over time then you need in eq (1) to change integration variables by : $W=\int _{a}^{b} {F(s)} \cdot ds = \int _{t_1}^{t_2} {F(t)} \cdot \frac {ds}{dt} dt = \int _{t_1}^{t_2} {F(t)} \cdot v(t) dt$
or you just calculate average/effective force $\overline F$ over path and use it as in normal work done scenario.
Anyway, after integration or using an average force, temporal information like $F(t)=ma(t)$ is lost.