FROM : Nick Zitzmann
DATE : Sun Apr 08 22:34:45 2007
On Apr 8, 2007, at 2:15 PM, محمد الركيان wrote:
> Hmm, this look easy, but I don't know why it doesn't work with me !!!
>
> All what I need is the current hour & minutes as int.
Try: (warning - written in Mail, untested, use at your own risk, etc.)
NSCalendarDate *now = [NSCalendarDate date];
int hour = [now hourOfDay];
int minute = [now minuteOfHour];
Alternately, this will work in Tiger and later, and is probably more
future-proof:
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *hourAndMinute = [cal components:NSHourCalendarUnit
| NSMinuteCalendarUnit fromDate:[NSDate date]];
int hour = [hourAndMinute hour];
int minute = [hourAndMinute minute];
Nick Zitzmann
<http://www.chronosnet.com/>
DATE : Sun Apr 08 22:34:45 2007
On Apr 8, 2007, at 2:15 PM, محمد الركيان wrote:
> Hmm, this look easy, but I don't know why it doesn't work with me !!!
>
> All what I need is the current hour & minutes as int.
Try: (warning - written in Mail, untested, use at your own risk, etc.)
NSCalendarDate *now = [NSCalendarDate date];
int hour = [now hourOfDay];
int minute = [now minuteOfHour];
Alternately, this will work in Tiger and later, and is probably more
future-proof:
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *hourAndMinute = [cal components:NSHourCalendarUnit
| NSMinuteCalendarUnit fromDate:[NSDate date]];
int hour = [hourAndMinute hour];
int minute = [hourAndMinute minute];
Nick Zitzmann
<http://www.chronosnet.com/>
| Related mails | Author | Date |
|---|---|---|
| ???? ??????? | Apr 8, 22:15 | |
| Nick Zitzmann | Apr 8, 22:34 | |
| Scott Stevenson | Apr 9, 00:03 | |
| Scott Stevenson | Apr 9, 00:13 |






Cocoa mail archive

