We consider a target problem for a nonlinear system under state constraints. We give a new continuous level-set approach for characterizing the optimal times and the backward-reachability sets. This approach leads to a characterization via a Hamilton-Jacobi equation, without assuming any controllability assumption. We also treat the case of time-dependent state constraints, as well as a target problem for a two-player game with state constraints. Our method gives a good framework for numerical approximations, and some numerical illustrations are included in the paper. Key words. Minimal time problem, Hamilton-Jacobi-Bellman equations, Level set method, Reachability set (Attainable set), State constraints, Two-players game. AMS subject classifications. 93B03, 49J15, 35A18, 65N15, 49Lxx