We study a system in which electrons in a two-dimensional electron gas are confined by a nonhomogeneous nuclear-spin polarization. The system consists of a heterostructure that has nonzero nuclei spins. We show that in this system electrons can be confined into a dot region through a local nuclear-spin polarization. The nuclear-spin-polarization-induced quantum dot has interesting properties indicating that electron energy levels are time dependent because of the nuclear-spin relaxation and diffusion processes. Electron confining potential is a solution of diffusion equation with relaxation. Experimental investigations of the time dependence of electron energy levels will result in more information about nuclear-spin interactions in solids