We introduce a numerical procedure to evaluate directly the probabilities of large deviations of physical quantities, such as current or density, that are local in time. The large-deviation functions are given in terms of the typical properties of a modified dynamics, and since they no longer involve rare events, can be evaluated efficiently and over a wider ranges of values. We illustrate the method with the current fluctuations of the Totally Asymmetric Exclusion Process and with the work distribution of a driven Lorentz gas.