NSString和NSDate的转换】的更多相关文章

输入的日期字符串形如:@"1992-05-21 13:08:08" - (NSDate *)dateFromString:(NSString *)dateString{ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss"]; NSDate *destDate= [dateFormatt…
c time_t 和 oc NSDate 的转换 1:time_t 转 oc NSDate time_t some_time_t=NULL; NSDate *someDate = [NSDate dateWithTimeIntervalSince1970:some_time_t]; 2: NSDate 转 time_t time_t unixTime = (time_t) [[NSDate date] timeIntervalSince1970]; - (NSTimeInterval)timeI…
//当前时间格式化, 例:YYYY-MM-dd-EEEE-HH:mm:ss + (NSString *)getCurrentDataWithDateFormate:(NSString *)formate { NSDate *now = [NSDate date]; return [self dateFormattingWithDate:now toFormate:formate]; } //任意NSDate格式化 + (NSString *)dateFormattingWithDate:(NSD…
記錄一下在 Objective-C 由 NSString 轉換為 NSDate 或 NSDate 轉換為 NSString 的方法. 很簡單,使用 NSDateFormatter 就可以令 NSString 和 NSDate 互相轉換. 由 NSDate 轉換為 NSString: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setTimeZone:[NSTimeZonetimeZ…
一个时间戳字符串:NSString *timeStampStr =  @"1441602721"; 转换成时间     double unixTimeStamp            = [timeStampStr doubleValue];            NSTimeInterval timeInterval = unixTimeStamp;            NSDate *date                = [NSDate dateWithTimeInterv…
NSNumber + (NSNumber *)numberWithInt:(int)value; + (NSNumber *)numberWithDouble:(double)value; - (int)intValue; - (double)doubleValue; NSNumber可以将基本数据类型包装起来,形成一个对象,这样就可以给其发送消息,装入NSArray中等等.NSNumber * intNumber=[NSNumber numberWithInt:100]:NSNumber *f…
一: NSDateFormatter *dateFormater = [[NSDateFormatter alloc]init]; [dateFormater setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSTimeZone* localzone = [NSTimeZone localTimeZone]; NSTimeZone* GTMzone = [NSTimeZone timeZoneForSecondsFromGMT:]; [dateFormat…
一.NSDate转NSString //获取系统当前时间 NSDate *currentDate = [NSDate date]; //用于格式化NSDate对象 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; //设置格式:zzz表示时区 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss zzz"]; //NSDate转NSString NSStrin…
用于uidate,picker.. +(NSDate*) convertDateFromString:(NSString*)uiDate{    NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ;    [formatter setDateFormat:@"yyyy年MM月dd日"];    NSDate *date=[formatter dateFromString:uiDate];    return date…
http://blog.sina.com.cn/s/blog_68661bd80101njdo.html 标签: ios时间戳 ios开发时间戳 ios16进制转中文 ios开发utf8转中文 ios汉字转utf8和16进   //获取当前系统的时间戳+(long)getTimeSp{    long time;    NSDate *fromdate=[NSDate date];    time=(long)[fromdate timeIntervalSince1970];    return…