Is there a better way to find midnight tomorrow?

前端 未结 6 2198
天涯浪人
天涯浪人 2021-02-13 22:05

Is there a better way to do this?

-(NSDate *)getMidnightTommorow {
    NSCalendarDate *now = [NSCalendarDate date];
    NSCalendarDate *tomorrow = [now dateByAdd         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-13 22:48

    Convert your current date and time to a Unix date (seconds since 1970) or DOS style (since 1980), then add 24 hours and convert it back. Then reset the hours, minutes and seconds to zero to get to midnight.

提交回复
热议问题