The "fundamental theorem of calculus" (part of it) says the if F(x)= \int f(x) dx, then dF/dx= f(x). That says that d/dx \int_a^x f(t)dt= f(x). (The other part says that if f(x)= dF/dx, then F(x)= \int f(x)dx+ C for some constant C.)
"Leibniz's formula" is more general:
\frac{d}{dx}\int_{\alpha(x)}^{\beta(x)} f(x,t)dt=f(x, \beta(x))\frac{d\beta(x)}{dx}- f(x, \alpha(x))\frac{d\alpha(x)}{dx}+ \int_{\alpha(x)}^{\beta(x)} \frac{\partial f(x, t)}{\partial x}dt.
The "fundamental theorem" is clearly a special case of "Leibniz's formula" with \alpha(x)= 0, so that d\alpha/dx= 0, \beta(x)= x so that d\beta/dx= 1 and f(t) not a function of x so that \partial f/\partial x= 0:
\frac{d}{dx}\int_0^x f(t)dt= (1)f(x)- (0)f(0)+ \int_0^x 0 dt= f(x).
To do the initial example, d/dx\int_0^x cos(t^2)dt, you just need the "fundamental theorem", d/dx\int_0^x cos(t^2)dt= cos(x^2).
To do the example elfmotat gives, d/dx \int_0^{x^2} cos(t^2)dt take \beta(x)= x^2, so that d\beta/dx= 2x, and \alpha(x)= 0. f(x, t)= cos(t^2) which does NOT depend on x so that \partial f/\partial x= 0. Leibniz' forumula becomes
2x cos((x^2)^2)- 0 cos(0^2)+ \int_0^{x^2} 0 dt= 2x cos(x^4).