纠结了我好几天终于搞明白了为什么字符串转date总是相差8个小时(时区不管怎么换都没有用,大家可以试一下,也可能是我的技术不好--)// 日期格式化 NSString *date = @"2015-01-10 20:40:30";NSDateFormatter *inputFormatter = [...
分类:
其他好文 时间:
2015-02-10 21:36:58
阅读次数:
178
#import #import "monthModel.h"#import "dayModel.h"#import "SolarAndLunerHeader.h"@interface PublicUtils : NSObject#pragma mark将时间本地化+(NSDate *)getLoca...
分类:
移动开发 时间:
2015-02-09 15:48:01
阅读次数:
254
应用中设置一般会存在这样的设置,如夜间勿扰模式,从8:00-23:00,此时如何判断当前时间是否在该时间段内。难点主要在于如何用NSDate生成一个8:00的时间和23:00的时间,然后用当前的时间跟这俩时间作对比就好了。下面提供两条思路:法1.用NSDate生成当前时间,然后转为字符串,从字符串中...
分类:
移动开发 时间:
2015-02-06 00:40:13
阅读次数:
249
取得当前的年月日,当前的时分秒获得,周几和星期几获得NSDate*date = [NSDate date];NSCalendar*calendar = [NSCalendar currentCalendar];NSDateComponents*comps; // 年月日获得comps =[calen...
分类:
移动开发 时间:
2015-02-05 12:48:38
阅读次数:
190
只能通过NSDate dateWithTimeIntervalSinceNow:方法获取前后68年的日期。
测试代码:
int now = [NSDate timeIntervalSinceReferenceDate];
NSDateFormatter *formatter = [NSDateFormatter new];
formatter.dateFormat =...
分类:
移动开发 时间:
2015-02-04 20:27:58
阅读次数:
505
/**
*NSDate和NSDateComponents
*/
/**
*创建标识今天的日期
*方法:NSDate中的date方法创建表示当前日期的对象
*/
NSDate *todaysDate=[NSDate date];
/**
*获取今天的日期列子
*/
#import
int main(int argc,const char *argv[...
分类:
其他好文 时间:
2015-02-03 19:26:44
阅读次数:
129
NSDate:5是坑啊啊! 1 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 2 3 [dateFormatter setDateFormat:@"yyyy/MM/dd hh:mm:ss"]; 4 ...
分类:
移动开发 时间:
2015-02-03 10:51:27
阅读次数:
213
NSData *data = [NSData data]; //获取当前时间
NSLog ("Today is %@", data);
NSArray *phrase;
phrase = [NSArray arrayWithObjects: @“x”, @“y”, @“z”, @“end”];
[phrase writeToFile: @“/tmp/...
分类:
其他好文 时间:
2015-01-30 06:50:49
阅读次数:
287
1、适合存储轻量级的本地数据。
2、NSUserDefaults支持的数据格式有:NSNumber、NSData、NSDate、NSString、NSArray、NSDictionary、BOOL
3、以键值对的形式进行存储
4、存储时间为整体应用程序的存储时间,如果想需要删除,需要删除整体应用程序
//初始化一个userDefaults
NSUserDefaults *defa...
分类:
移动开发 时间:
2015-01-29 12:45:54
阅读次数:
224
//
// main.m
// OC05-task-06
//
// Created by Xin the Great on 15-1-26.
// Copyright (c) 2015年 Xin the Great. All rights reserved.
//
#import
int main(int argc, const char * argv[]) {
@auto...
分类:
其他好文 时间:
2015-01-27 21:56:17
阅读次数:
163