如何在iOS中使用NSDate获得星期几并在NSLog中显示? [英] how do I get the day of the week using NSDate and show using NSLog in iOS?

查看:180
本文介绍了如何在iOS中使用NSDate获得星期几并在NSLog中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
目标C-如何从NSDate获取工作日?

Possible Duplicate:
Objective C - How can i get the weekday from NSDate?

如何使用NSDate获得星期几并使用NSLog显示?

How do I get the day of the week using NSDate and show using NSLog?

我想知道今天,例如今天.

I wonder the current day, such as today.

例如:NSLog(@"day is:",day)
响应:一天是:星期一"

Ex: NSLog(@"the day is:",day)
Resp: "the day is: Monday"

推荐答案

NSDateFormatter* day = [[NSDateFormatter alloc] init];
[day setDateFormat: @"EEEE"];
NSLog(@"the day is: %@", [day stringFromDate:[NSDate date]]);

这篇关于如何在iOS中使用NSDate获得星期几并在NSLog中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆