Based on the nonequilibrium Green's function (NEGF) and time-dependent density-functional theory (TDDFT), we propose a formalism to study the time-dependent transport behavior of molecular devices from first principles. While this approach is equivalent to the time-dependent wave-function approach within TDDFT, it has the advantage that the scattering states and bound states are treated on equal footing. Furthermore, it is much easier to implement our approach numerically. Different from the time-dependent wave-function $[\ensuremath{\psi}(t,E)$] approach, our formalism is in the time space [${\mathbf{G}}^{r}(t,{t}^{\ensuremath{'}})$], making this method superior in the time-dependent transport problem with many subbands in the transverse direction. For the purpose of numerical implementation on molecular devices, a computational tractable numerical scheme is discussed in detail. We have applied our formalism to calculate the transient current of two molecular devices Al-1,4-dimethylbenzene-Al and Al-benzene-Al from first principles. In the calculation, we have gone beyond the wideband limit and used the adiabatic local density approximation that was used within TDDFT. It is known that when the wideband limit is abandoned, the boundary condition of the transport problem is non-Markovian, resulting in a memory term in the effective Hamiltonian of the scattering region. To overcome the computational complexity due to the memory term, we have employed a fast algorithm to speed up the calculation and reduced the CPU time from the scaling ${N}^{3}$ to ${N}^{2}{\mathrm{log}}_{2}^{2}(N)$ for the steplike pulse, where $N$ is the number of time steps in the time evolution of the Green's function. To ensure the accuracy of our method, we have done a benchmark transient calculation on an atomic junction using a time-dependent wave-function approach within TDDFT in momentum space, which agrees very well with the result from our method.