Ab initio constant pressure molecular dynamics simulations within a generalized gradient approximation (GGA) are carried out to study the structural phase transformation of ZnSe under hydrostatic and nonhydrostatic conditions. ZnSe undergoes a first-order phase transition from the zinc-blende structure to a rocksalt structure having practically identical transformation mechanisms under hydrostatic and nonhydrostatic compressions. This phase transformation is also analyzed using the enthalpy calculations. Our transition parameters and bulk properties are comparable with experimental and theoretical data. Furthermore, the influence of pressure on the electronic structure of ZnSe is investigated. It is found that the band gap energy increases nonlinearly under both hydrostatic and nonhydrostatic conditions and the effect of stress deviations on the band gap energy is small. The computed pressure coefficients and deformation potential of the band gap are in good agreement with experiments.