If you'd also like to include the effect of existing assets, there's also a formula first posted in these forums (AFAIK) by
Heart of Tin:
Time in years to FI = Ln((S + i*E/WR) / (S + i*A)) / Ln(1 + i)
A = Asset amount currently invested in funds you will draw upon in retirement.
E = Total (including taxes) annual expenses in retirement
i = Real return on invested retirement funds.
S = Annual amount invested in funds you will draw upon in retirement.
WR = Withdrawal Rate planned for retirement, using Trinity Study definitions.
Networthify uses an equivalent form of this equation, with
“Current annual savings” = S,
“Current annual expenses” = E,
“Current portfolio value” = A,
“Annual return on investment” = i,
“Withdrawal rate” = WR.