Java getHours(), getMinutes() and getSeconds()

Try this: Calendar calendar = Calendar.getInstance(); calendar.setTime(yourdate); int hours = calendar.get(Calendar.HOUR_OF_DAY); int minutes = calendar.get(Calendar.MINUTE); int seconds = calendar.get(Calendar.SECOND); Edit: hours, minutes, seconds above will be the hours, minutes and seconds after converting yourdate to System Timezone!

How to convert an NSTimeInterval (seconds) into minutes

Brief Description The answer from Brian Ramsay is more convenient if you only want to convert to minutes. If you want Cocoa API do it for you and convert your NSTimeInterval not only to minutes but also to days, months, week, etc,… I think this is a more generic approach Use NSCalendar method: (NSDateComponents *)components:(NSUInteger)unitFlags … Read more

How to get time difference in minutes in PHP

The answers above are for older versions of PHP. Use the DateTime class to do any date calculations now that PHP 5.3 is the norm. Eg. $start_date = new DateTime(‘2007-09-01 04:10:58’); $since_start = $start_date->diff(new DateTime(‘2012-09-11 10:25:00′)); echo $since_start->days.’ days total<br>’; echo $since_start->y.’ years<br>’; echo $since_start->m.’ months<br>’; echo $since_start->d.’ days<br>’; echo $since_start->h.’ hours<br>’; echo $since_start->i.’ minutes<br>’; … Read more