美文网首页
用日历NSCalendar获取年月日时分秒

用日历NSCalendar获取年月日时分秒

作者: 奋斗吧程序员 | 来源:发表于2019-04-28 16:13 被阅读0次

[[NSCalendar currentCalendar] components:NSCalendarUnitYear  fromDate:self].year;

[[NSCalendar currentCalendar] components:NSCalendarUnitMonth fromDate:self].month; 

[[NSCalendar currentCalendar] components:NSCalendarUnitDay  fromDate:self].day;

[[NSCalendar currentCalendar] components:NSCalendarUnitHour  fromDate:self].hour; 

[[NSCalendar currentCalendar] components:NSCalendarUnitMinute  fromDate:self].minute; 

[[NSCalendar currentCalendar] components:NSCalendarUnitSecond  fromDate:self].second;

[[NSCalendar currentCalendar] components:NSCalendarUnitWeekday  fromDate:self].weekday;

相关文章

  • 用日历NSCalendar获取年月日时分秒

    [[NSCalendar currentCalendar] components:NSCalendarUnitYe...

  • iOS中NSCalendar使用

    NSCalendar封装了系统如何按照年月日的方式来组织时间,快速获取日期对象的年月日、时分秒等相关信息。 1.获...

  • NSCalendar使用

    一、NSCalendar NSCalendar可以很方便的用来表示日期,获取日期的各种信息,包括年、月、日,时分秒...

  • NSCalendar扫盲

    一、NSCalendar NSCalendar可以很方便的用来表示日期,获取日期的各种信息,包括年、月、日,时分秒...

  • 常用函数

    时间日期函数 1、获取当前系统时间,时间格式包括年月日时分秒 2、只获取系统时分秒 3、只获取当前系统时间的年月日...

  • Swift与OC比较之NSDateComponents

    用NSDateComponents计算时间差 先来看OC //获取日历对象NSCalendar *cal = [N...

  • Go语言获取时间和日期

    如何获取当前时间time.now() 如何获取当前的年月日时分秒now.年月日时分秒 如何按照我们指定的格式生成时...

  • 关于前端时间的那些事

    1.如何获取系统时间 显示最终结果: 2.如何获取年月日时分秒 3.如何设置年月日时分秒 4. momentjs强...

  • Android 获取当前时间及时间戳的互换

    在项目开发中,难免会遇到使用当前时间,比如实现网络请求上传报文、预约、日历等功能。 1. 获取年月日时分秒 在获取...

  • 关于时间的方法

    1.获取前后几天的时间(年月日) 2.获取当前时间(年月日时分秒) 3.获取今天星期几

网友评论

      本文标题:用日历NSCalendar获取年月日时分秒

      本文链接:https://www.haomeiwen.com/subject/qmqjnqtx.html