The current through a capacitor as a function of time is given by;
$$i(t)=C\cdot \frac{d}{dt}U(t)$$
When assuming that the capacitance $C$ does not vary with time.
But what if it does?
I don't know how to derive the equation above from Gauss's law, so here is instead my attempt at a "common-sense" kind of solution, I don't know whether this is valid or nonsense.
Integrating the equation above;
$$Q(t)=\int i(t) dt=C\cdot U(t)$$
..we get the equation for charge $Q=C\cdot U$,
I assume that this is always valid, even if $C$ is a function of time (let's ignore relativity and quantum mechanics for a moment).
If that is true then to get back to the original equation all I need to do is differentiate, this time letting $C$ be a function of time;
$$i(t)=\frac{d}{dt}Q(t)=\frac{d}{dt}[C(t)\cdot U(t)]=\frac{d}{dt}C(t)\cdot U(t)+C(t)\cdot \frac{d}{dt}U(t)$$
..which gives the result;
$$i(t)=\frac{d}{dt}C(t)\cdot U(t)+C(t)\cdot \frac{d}{dt}U(t)$$
Is this equation valid? Or how do you solve for the current through a capacitor with varying capacitance and voltage?