We present a variational method for recovering the phase term from the information obtained from phase-shifting methods. First we introduce the new method based on a variational approach and then describe the numerical solution of the proposed cost function, which results in a simple algorithm. Numerical experiments with both synthetic and real fringe patterns shows the accuracy and simplicity of the resulting algorithm.