Add 1 Week to a Date, which way is preferred?

前端 未结 10 1780
迷失自我
迷失自我 2021-01-07 17:30

I am reviewing some code at work and came across an inconsistency in how the code handles adding 1 week to the current time and was wondering if there was any reason why one

10条回答
  •  醉酒成梦
    2021-01-07 18:11

    The two methods will behave differently on daylight savings boundaries. The first method will continue returning the same time of the day, regardless of daylight savings status. The second method will return times which vary an hour in each direction as daylight savings time starts and stops.

提交回复
热议问题