• NSDate 时间


          NSDate *date =[NSDate date];

            

            NSLog(@"****%@",date);

            //获取明天此时的时间以当前时间为准 时间间隔单位为 秒(以秒为时间单位计算时间间隔)

            NSDate *tomorrw = [NSDate dateWithTimeIntervalSinceNow:24*60*60];//从现在多少秒之后

            NSLog(@"tomorrw:%@",tomorrw);

            NSTimeInterval tim1970 =[date timeIntervalSince1970];//距1970多少秒

            NSLog(@"%f",tim1970);

            //格式化输出

            NSDateFormatter *dateFormater =[[NSDateFormatter alloc]init];

            [dateFormater setDateFormat:@"yyyy年MM月dd日 HH:mm:ss"];

            NSString *dateString = [dateFormater stringFromDate:date];

            NSLog(@"%@",dateString);

    //根据秒数获取时间

       long long time = [[bigDic objectForKey:@"setoff_date"] longLongValue];

                 NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:time];

                NSDateFormatter *dateFormater =[[NSDateFormatter alloc]init];

                [dateFormater setDateFormat:@"yyyy-MM-dd"];

                  NSString *dateString = [dateFormater stringFromDate:confromTimesp];

                

    //获取周几.

    - (NSString *)getWeekDayFordate:(long long)data

    {

        NSArray *weekday = [NSArray arrayWithObjects: [NSNull null], @"周日", @"周一", @"周二", @"周三", @"周四",@"周五", @"周六", nil];

        

        NSDate *newDate = [NSDate dateWithTimeIntervalSince1970:data];

        NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

        NSDateComponents *components = [calendar components:NSWeekdayCalendarUnit fromDate:newDate];

        

        NSString *weekStr = [weekday objectAtIndex:components.weekday];

        return weekStr;

    }

    typedef CF_ENUM(CFIndex, CFDateFormatterStyle) {    // date and time format styles

        kCFDateFormatterNoStyle = 0,       // 无输出

        kCFDateFormatterShortStyle = 1,    // 12-10-29 下午2:52

        kCFDateFormatterMediumStyle = 2,   // 2012-10-29 下午2:51:43

        kCFDateFormatterLongStyle = 3,     // 2012年10月29日 GMT+0800下午2时51分08秒

        kCFDateFormatterFullStyle = 4      // 2012年10月29日星期一 中国标准时间下午2时46分49秒

    };

  • 相关阅读:
    Go语言开发Windows应用
    go 调用windows dll 的方法
    thinkPHP5 命名空间别名
    thinkPHP5 类库包注册
    thinkphp5 默认配置代码
    edusoho twig 引入文件功能
    edusoho 查找网址对应的控制器和模板页面
    启动Nginx 出现 nginx: [emerg] unknown directive "锘?user" 错误
    eduSOHO 首页模板 全部课程模块代码
    twig 模板控制器对应列表
  • 原文地址:https://www.cnblogs.com/wukun168/p/6010818.html
Copyright © 2020-2023  润新知