//
// 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;
}

NS-Date/NSDateFormatter的更多相关文章

  1. Foundation框架下的常用类:NSNumber、NSDate、NSCalendar、NSDateFormatter、NSNull、NSKeyedArchiver

    ========================== Foundation框架下的常用类 ========================== 一.[NSNumber] [注]像int.float.c ...

  2. NSDateFormatter

    NSDate *now = [NSDate date]; NSDateFormatter *fmt = [[NSDateFormatter alloc] init]; fmt.dateFormat = ...

  3. SugarSync网盘之NSDateFormatter

    NSDateFormatter 在获取sugarsync网盘的accessToken时候,得到了过期时间.但是这里的过期时间采用的是世界标准时间UTC,而该网盘是国外的,所以在国内显示的时间就不对了, ...

  4. iOS-时间戳(或date)转字符串

    1.时间戳转字符串 ///时间戳转化为字符转0000-00-00 00:00 + (NSString *)time_timestampToString:(NSInteger)timestamp{ NS ...

  5. objc:NSDateFormatter使用备忘

    NSDateFormatter类的实例可以将字符串的日期表示转换为NSDate对象或者反向转换. 如果只要显示日期不需要时间,则可以用-setDateStyle方法来设置显示日期的格式,有以下几种: ...

  6. iOS开发--NSDateFormatter

    NSDate对象包含两个部分,日期(Date)和时间(Time).格式化的时间字符串主要也是针对日期和时间的 1.基础用法 NSDate* now = [NSDate date]; NSDateFor ...

  7. iOS 小知识点(持续更新)

    1.如何通过代码设置Button  title的字体大小 设置Button.titleLabel.font = [UIFont systemFontOfSize:<#(CGFloat)#> ...

  8. iOS JsonModel 的使用

    本文转自:http://blog.csdn.net/smking/article/details/40432287 下面讲一下JSONModel的使用方法. @inteface MyModel : J ...

  9. JSONModel解析数据成Model

    转自:http://blog.csdn.net/smking/article/details/40432287 JSONModel, Mantle 这两个开源库都是用来进行封装JSON->Mod ...

  10. iOS JsonModel

    iOS JsonModel 的使用 本文转自:http://blog.csdn.net/smking/article/details/40432287 下面讲一下JSONModel的使用方法. @in ...

随机推荐

  1. notepad++ 输入中文无响应

    如果是win7,到用户文件夹 C:\Users\xxxxxxxx\AppData\Roaming\Notepad++ 里面的config.xml 删掉,然后重新打开,应该就可以了,  代价是会删除之前 ...

  2. VS2012开发ActiveX插件 尝试1

    今天闲来无聊研究了下 ActiveX插件开发,以前一直以为很牛逼,然后发现还是比较简单的东西.. 首先: 在开始前 准备好 VS12开发工具,cabarc.exe 工具(注:这是 用来 将文件打包成c ...

  3. 从零开始学android开发-View的setOnClickListener的添加方法

    1)第一种,也是最长见的添加方法(一下都以Button为例) Button btn = (Button) findViewById(R.id.myButton); btn .setOnClickLis ...

  4. 实时数据采集传输软件LDM配置

    本环境一共两个机器:cma.ldm87.gov.cn(hostname)机器作为upstream LDM,cma.ldm84.gov.cn(hostname)机器作为downstream LDM.下面 ...

  5. Android 滑动效果高级篇(七)—— 华丽翻页效果

    By 何明桂(http://blog.csdn.net/hmg25) 转载请注明出处 之前看到像ipad上的ibook的模拟书籍翻页的特效感觉很炫,在android上也有像laputa和ireader ...

  6. js 控制div 显示隐藏的问题

    var divs = document.getElementsByTagName("div");得到所有的divfor(var i=0;i<divs.length;i++){ ...

  7. (ios开发学习笔记一)ios项目文件结构

    转自:http://www.cnblogs.com/macroxu-1982/archive/2012/07/31/2616389.html 下面是单个窗体项目例子,我们从这个项目开始,说明ios项目 ...

  8. C#_模拟webAp_POST-GET-PUT-DELETE

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...

  9. c实例_挑战程序竞赛,蚂蚁

    #include <stdio.h> //蚂蚁的题目 int max(int a,int b) { int count; count=a>b?a:b; return count; } ...

  10. javaEE学习笔记-利用DOM4J解析xml至数据库

    xml代码文件名:test02.xml <ACCESOS> <item> <SOCIO> <NUMERO>00045050</NUMERO> ...