- 浏览: 884397 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (466)
- iPhone, iOS , Objective-c (155)
- 数据库 (20)
- 设计模式 (5)
- 第三方包管理,cocoapod (2)
- 版本管理, SVN, Subversion, Git (1)
- Google, Android, Java (14)
- Wordpress (1)
- 职业素养 (3)
- 版本管理,git (3)
- 前端小技巧 (2)
- flash (1)
- javascript (5)
- Ruby (0)
- 编程语言 (1)
- 网络常识 (1)
- 找到生活好感觉 (5)
- 产品经理 (1)
- markdown (1)
- 云服务器 (1)
- iPhone (116)
- iOS (116)
- Objective-c (116)
- 学习技巧 (2)
- Google (5)
- Android (6)
- Java (21)
- python (1)
- sqlite (3)
- node.js (2)
- mongodb (2)
- 学习技巧,阅读 (2)
- 软件测试 (3)
- 架构设计 (2)
- 设计 (1)
- Spring framework (3)
- junit (1)
- Linux (2)
- 软件 (1)
- Struts2 (1)
- 版本管理 (3)
- SVN (3)
- Subversion (3)
- Git (3)
- mysql (5)
- quartz (1)
- 无关技术 (1)
- 前端 (1)
- Redis (1)
- 产品管理 (0)
- 计算机常识 (1)
- 计算机科学 (0)
- swift (1)
- 服务器 (2)
- 搜索 (1)
- Scala (1)
- J2EE (1)
- maven (1)
- 前端css (1)
- 英语 (1)
- 消息队列 (1)
- kafka (0)
- apache kafka (4)
- netbeans (1)
- IDE (2)
- 歌词 (1)
- 过滤器实现 (1)
- linux vim vi (1)
- jmeter (1)
- springcloud (1)
最新评论
-
hujingnemo:
不知道为什么打不开
CHM如何改编字体大小 -
weiboyuan:
求答案 weiboyuanios@163.com
iOS软件工程师面试题(高级) -
xueji5368:
这个现在已经广泛使用了嘛!
RoboGuice入门 -
Yao__Shun__Yu:
...
CHM如何改编字体大小 -
353144886:
非常之详细 美女求认识
sqlite数据类型 datetime处理
//中国时区时间
[NSTimeZone setDefaultTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT+0800"]];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSLog(@"%@",[dateFormatter stringFromDate:date]);
//显示星期几
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"]];
dateFormatter.dateFormat = @"yyyy-MM-dd EEEE";
//得到当前的日期
NSDate *date = [NSDate date];
NSLog(@"date:%@",date);
//得到(24 * 60 * 60)即24小时之前的日期,dateWithTimeIntervalSinceNow:
NSDate *yesterday = [NSDate dateWithTimeIntervalSinceNow: -(24 * 60 * 60)];
NSLog(@"yesterday:%@",yesterday);
NSDateFormatter *formatter =[[[NSDateFormatter alloc] init] autorelease];
NSDate *date = [NSDate date];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDateComponents *comps = [[[NSDateComponents alloc] init] autorelease];
NSInteger unitFlags = NSYearCalendarUnit |
NSMonthCalendarUnit |
NSDayCalendarUnit |
NSWeekdayCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit;
//int week=0;
comps = [calendar components:unitFlags fromDate:date];
int week = [comps weekday];
int year=[comps year];
int month = [comps month];
int day = [comps day];
//[formatter setDateStyle:NSDateFormatterMediumStyle];
//This sets the label with the updated time.
int hour = [comps hour];
int min = [comps minute];
int sec = [comps second];
NSLog(@"week%d",week);
NSLog(@"year%d",year);
NSLog(@"month%d",month);
NSLog(@"day%d",day);
NSLog(@"hour%d",hour);
NSLog(@"min%d",min);
NSLog(@"sec%d",sec);
//得到毫秒
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
//[dateFormatter setDateFormat:@"hh:mm:ss"]
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];
NSLog(@"Date%@", [dateFormatter stringFromDate:[NSDate date]]);
[dateFormatter release];
/**
* 取最近七天的时间
**/
- (void)receiveCurrentTime:(NSNotification*)notify
{
NSDictionary *dic = [notify userInfo];
NSDate *currentDate = [dic objectForKey:currentTimeResult];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"]];
dateFormatter.dateFormat = @"yyyy-MM-dd EEEE";
NSMutableArray *dateslist = [[NSMutableArray alloc] init];
for (int i = 0; i < 7; i++) {
NSDate *newDate = [[NSDate alloc] initWithTimeIntervalSinceReferenceDate:([currentDate timeIntervalSinceReferenceDate] + 24*3600*i)];
[dateslist addObject:newDate];
NSString *str = [NSString stringWithFormat:@"%@", [dateFormatter stringFromDate:newDate]];
[_dateList addObject:str];
}
NSString *defaultDateStr = [self transToSendDateString:currentDate];
_requestSeat.dateStr = defaultDateStr;
_dates = dateslist;
}
[NSTimeZone setDefaultTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT+0800"]];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSLog(@"%@",[dateFormatter stringFromDate:date]);
//显示星期几
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"]];
dateFormatter.dateFormat = @"yyyy-MM-dd EEEE";
//得到当前的日期
NSDate *date = [NSDate date];
NSLog(@"date:%@",date);
//得到(24 * 60 * 60)即24小时之前的日期,dateWithTimeIntervalSinceNow:
NSDate *yesterday = [NSDate dateWithTimeIntervalSinceNow: -(24 * 60 * 60)];
NSLog(@"yesterday:%@",yesterday);
NSDateFormatter *formatter =[[[NSDateFormatter alloc] init] autorelease];
NSDate *date = [NSDate date];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDateComponents *comps = [[[NSDateComponents alloc] init] autorelease];
NSInteger unitFlags = NSYearCalendarUnit |
NSMonthCalendarUnit |
NSDayCalendarUnit |
NSWeekdayCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit;
//int week=0;
comps = [calendar components:unitFlags fromDate:date];
int week = [comps weekday];
int year=[comps year];
int month = [comps month];
int day = [comps day];
//[formatter setDateStyle:NSDateFormatterMediumStyle];
//This sets the label with the updated time.
int hour = [comps hour];
int min = [comps minute];
int sec = [comps second];
NSLog(@"week%d",week);
NSLog(@"year%d",year);
NSLog(@"month%d",month);
NSLog(@"day%d",day);
NSLog(@"hour%d",hour);
NSLog(@"min%d",min);
NSLog(@"sec%d",sec);
//得到毫秒
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
//[dateFormatter setDateFormat:@"hh:mm:ss"]
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];
NSLog(@"Date%@", [dateFormatter stringFromDate:[NSDate date]]);
[dateFormatter release];
/**
* 取最近七天的时间
**/
- (void)receiveCurrentTime:(NSNotification*)notify
{
NSDictionary *dic = [notify userInfo];
NSDate *currentDate = [dic objectForKey:currentTimeResult];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"]];
dateFormatter.dateFormat = @"yyyy-MM-dd EEEE";
NSMutableArray *dateslist = [[NSMutableArray alloc] init];
for (int i = 0; i < 7; i++) {
NSDate *newDate = [[NSDate alloc] initWithTimeIntervalSinceReferenceDate:([currentDate timeIntervalSinceReferenceDate] + 24*3600*i)];
[dateslist addObject:newDate];
NSString *str = [NSString stringWithFormat:@"%@", [dateFormatter stringFromDate:newDate]];
[_dateList addObject:str];
}
NSString *defaultDateStr = [self transToSendDateString:currentDate];
_requestSeat.dateStr = defaultDateStr;
_dates = dateslist;
}
发表评论
-
UIImage变为NSData并进行压缩
2014-05-19 20:23 1867//sdk中提供了方法可以直接调用 UIImage *im ... -
update cocapods
2014-05-17 22:27 762早上更新cocoapod依赖库,发现更新到32.1版本,早先的 ... -
iOS发送短信息代码实例
2014-05-16 18:15 2625#import <MessageUI/Message ... -
DISPATCH TIMER
2014-05-14 16:12 665/* __block void (^callback) ... -
UITextField左边显示图片
2014-05-13 18:08 1099The overlay view displayed on t ... -
iOS调用系统打电话,发短信功能
2014-05-11 15:48 2048先介绍一种最简单的方法: 调用打电话功能 [[UIAppl ... -
iOS面试题
2014-05-09 16:10 10351.写一下UIButton与UITableView的层级结构 ... -
socket二进制报文
2014-05-09 15:18 1240里面有帧头 字符串UTF-8 中间用0隔开 又一个字符串 ... -
将网站添加到桌面的方法
2014-05-08 14:25 1617<link href="http://www. ... -
iPhone通讯录联系人操作大全
2014-05-07 10:29 13941.需要引入AddressBook.framework框架 2 ... -
sqlite获取最新插入的rowid
2014-05-07 09:59 1468除了 last_insert_rowid select max ... -
号码归属地查询,拨打电话
2014-05-06 15:07 793在程序内调用拨打电话的方法,[[UIApplication s ... -
iOS时间合并
2014-04-28 17:55 1012合并同一时间的课程,同一时间可能有多个课程,比如13:30-1 ... -
vCard通讯录格式说明
2014-04-28 16:47 2418原帖:http://freesoftman.iteye.com ... -
UISearchBar背景色全套解决方案
2014-04-25 09:36 7387os系统升级到7.1后,原来在7.0下显示正常的UISearc ... -
升级XCode5.1.1遇到的奇葩问题NSString,NSObjectRuntime.h报错,Foundation找不到
2014-04-24 11:19 849升级XCode5.1.1遇到的奇葩问题NSString,NSO ... -
将NSString转为NSArray
2014-04-22 16:52 6226// Your JSON data: NSString *c ... -
另外一种NSData转为NSString的方法
2014-04-22 15:40 1163If the data is not null-termina ... -
HTTP,Socket,WebSocket异同
2014-04-18 16:54 1784参考文章: http://abbshr.g ... -
push隐藏UINavigtaionBar和UITabbar
2014-04-17 15:20 1039[self.navigationController setN ...
相关推荐
NULL 博文链接:https://o0o0o0o.iteye.com/blog/588887
Swift-NSDate-Extensions 是 Swift NSDate 扩展,帮助开发。 标签:Swift
主要给大家介绍了关于iOS将时间NSDate转化为毫秒时间戳的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
NSDate总结,NSDateFormatter总结,NSCalender总结,倒计时(60秒倒计时,天数倒计时,cell上天数倒计时)
NSDate时间
DateHelper - NSDate在Swift中的便利扩展
object-c基础语法NSDate, 适合初学者,主要学习NSDate的设置、获取当前时间、当前时间加减秒后的时间、日期比较、日期转换成NSString等
NSDate分类,获得对应中国农历
说明请看:http://blog.csdn.net/dolacmeng/article/details/51344748
单例封装NSDateFormatter,根据需求自由封装显示时间格式
NSDate,iphone显示时间,日期的方法集合
iOS时间戳字符串NSDate转化demo
一系列关于Date的小方法,包括NSDate和NSString的互相转换,大家自己看看每个方法的说明吧!
iOS ,扩展NSFDate , 可以帮助开发相关
NSDate-DaboExtensionNSDate分类支持Pod导入pod 'NSDate-DaboExtension', '~> 1.0.0'
时间范围 TimeRange 提供检查 NSDate 是否发生在两个其他 NSDates 之间。 检查 NSDate 是否包含 TimeRange。(例如12:00包含10:00 ~ 20:00 ) 检查一个 TimeRange 是否与另一个 TimeRange 重叠。安装TimeRange 可...
NSDate-RFC1123 在Swift中实现HTTP日期 ,以解析类似Last-Modified的HTTP标头
NSDate扩充功能,可更容易操作NSDate ,它建立在SWIFT的顶部功能提供最好的体验和安全性。特征使用常用比较运算符比较日期: >, >=, <, <= 使用该自定义运算符获取日期之间的间隔>-< 使用算术运算符添加/...
//返回月日 - (NSString *)getFormatMonthDay; //返回当前月一共有几周(可能为4,5,6) - (int )getWeekNumOfMonth; //该日期是该年的第几周 - (int )getWeekOfYear; //返回day天后的日期(若day为负数,则为|day|天前的...