使用Cocoa确定两个日期之间的月数 [英] Determine the number of months between two dates using Cocoa

查看:133
本文介绍了使用Cocoa确定两个日期之间的月数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Cocoa计算两个日期之间的月数?

How do I calculate the number of months between two dates using Cocoa?

谢谢,
Stan

Thanks, Stan

推荐答案

查看NSCalendars components:fromDate:toDate:options 方法。它允许您减去日期,然后提取月属性值

Look at NSCalendars components:fromDate:toDate:options method. It allows you to subtract dates and then extract the months property value

这篇关于使用Cocoa确定两个日期之间的月数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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