IOS NSDate 调整当前时间戳为明天
2024-08-23 06:29:48
这个可以根据需要调整 在day month hour minute second 等都行
以下是以当前时间戳为基础,调整时间为明天的零点零时零分零秒 可以根据需要 写成毫秒的
+(NSString *)GetTomorrowDay:(NSDate *)aDate
{
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorian components:NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:aDate];
[components setDay:([components day]+)]; NSDate *beginningOfWeek = [gregorian dateFromComponents:components];
// // // //
NSDateFormatter *dateday = [[NSDateFormatter alloc] init];
[dateday setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
[dateday stringFromDate:beginningOfWeek];
DLog(@"%@",[dateday stringFromDate:beginningOfWeek]);//年月日 时分秒
// // // //
DLog(@"%@",[NSString stringWithFormat:@"%ld", (long)[beginningOfWeek timeIntervalSince1970]]);//时间戳
return @"";//喜欢用啥 就返回啥吧
}
调用方法 NSLog(@"%@",[self GetTomorrowDay:[NSDate date]]);
最新文章
- Codeforces #380 Subordinates(贪心 构造)
- JavaScript 数据类型
- property animation ( NineOldAndroid )
- 关于 android 开发中 debug不能顺利进行的各种问题的总结
- tp_link路由器 重新设置
- iOS:核心动画之转场动画CATransition
- android开发,assets下面的资源文件不会变化/改动
- web.xml文件中配置ShallowEtagHeaderFilter需注意的问题
- SQL Server 查看数据页面
- github--hello,world(参考官网)
- Python基础(set集合)
- Python函数基础--def及return语句地操作
- MySQL数据库优化_索引
- Java随机字符串:随机数字字符串,工具类
- Failed to load bundle(http://loaclhost:8081/index.bundle?platfrom=ios.....
- Linux基础笔记——RAID
- (效率低下)77. Combinations C++回溯法 组合
- WAF Bypass数据库特性(Oracle探索篇)
- NGINX防御CC攻击教程
- 2015第六届蓝桥杯C/C++ B组