As we have explained before (see here) during Shabbat we can't turn on or off any electrical appliance or lights. However, it is permitted to program a timer (sha'on Shabbat) from Friday, before Shabbat begins, to turn on and off lights or some other electrical appliances.
Modern Rabbis discussed the issue of modifying the time of the timer during Shabbat. For example, if I programmed the timer to turn off the lights at 10.30 p.m., and then I realize that I will need the lights for one more hour, can I reprogram the timer to turn off the lights at 11.30 p.m.?
Many Rabbis would forbid to do this, but Rabbi Obadia Yosef, Rabbi Auerbach and many other Rabbis authorize to reprogram the timer in the following circumstances:
1. First, it should be a manual timer (see for example this) , not a digital timer (see this ). A digital timer cannot be modified during Shabbat.
2. When dealing with a manual timer we would be allowed to move the knobs forward, but not back to turn the lights off or even on. We could move the knobs, for example, from 1.30 p.m. to 2.30 p.m., but not from 2.30 p.m. to 1.30 p.m..
3. Rabbi Melamed says (Penine Halakha, Shabbat B, p.24) that in exceptional circumstances (sha'at hadaḥaq) most Rabbis would also authorize to reprogram the timer to turn off the lights at an earlier time. Rabbi Yosef mentions the case of a sick person (even in a non-life threatening situation) for example, if the lights don't allow him or her to rest. Similarly, in certain cases (leṣorekh Miṣva) we would be allowed to reprogram the timer to turn the lights on at an earlier time. Rabbi Yosef mentions as an example, Limud Tora.
Candle lighting in NYC: 4:31 p.m.
Shabbat ends in NYC: 5:38 p.m.