//
//  main.m
//  NS-Date
//
//  Created by qianfeng on 15/6/23.
//  Copyright (c) 2015年 qianfeng. All rights reserved.
//

#import <Foundation/Foundation.h>
//DSdate
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        //格林威治时间
        //获取当前时间
        NSDate *date =[NSDate date];
        NSLog(@"%@",date);
        //当前时间加上时间间隔后的时间点
        NSDate *date1 =[NSDate dateWithTimeIntervalSinceNow:120];
        NSLog(@"%@",date1);
        NSLog(@"%@",[NSDate distantFuture]);
        
        NSLog(@"%f", [date timeIntervalSinceNow]);
        //时间戳类
        //YY 或 yy 或 YYYY //yyyy 年份
        //MM .MMMM,MMM,M,
        //dd 表示一个月的第多少天
        //DD 表示一年的第多少天
        //hh;12进制的时间,HH:24进制时间
        //ss:表示秒数  SS表示毫秒 以100为单位
        NSDateFormatter *dateFormatter =[[NSDateFormatter alloc] init];
        dateFormatter.dateFormat =@"yy/MM/dd hh:mm:ss";
        
        NSString *dateString =[dateFormatter stringFromDate:[NSDate date]];
        NSLog(@"%@",dateString);
        //把时间字符串转换成时间,按照指定格式.
        NSLog(@"%@",[dateFormatter dateFromString:@"2014/09/12 12:11:22"]);
    }
    return 0;
}

 

相关文章:

  • 2021-07-08
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-26
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
相关资源
相似解决方案