hour

How do I get hour and minutes from NSDate?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 10:20:53
In my application I need to get the hour and minute separately: NSString *currentHour=[string1 substringWithRange: NSMakeRange(0,2)]; int currentHourInNumber=[currentHour intValue]; Consider string1 contains 11:59:13 AM which is coming from datepicker. Here if I use above code, it's okay to get hour if it's greater than 9. Else I need to change NSMakeRange(0,1) to get hour between 1 to 9. Are there any methods to get the hour, minutes, etc? Thanks in advance, please provide me sample code. Thomas Müller Use an NSDateFormatter to convert string1 into an NSDate , then get the required

Extracting hours from a DateTime (SQL Server 2005)

本秂侑毒 提交于 2019-11-27 07:21:06
I can extract the month and day by using Day(Date()) , Month(Date()) . I can't extract hours, with HOUR(Date()) . I get the following error. 'HOUR' is not a recognized built-in function name. How can I extract hours? Dave Markle SELECT DATEPART(HOUR, GETDATE()); DATEPART documentation ... you can use it on any granularity type i.e.: DATEPART(YEAR, [date]) DATEPART(MONTH, [date]) DATEPART(DAY, [date]) DATEPART(HOUR, [date]) DATEPART(MINUTE, [date]) (note: I like the [ ] around the date reserved word though. Of course that's in case your column with timestamp is labeled "date") Adrian Godong Use

How to do a cron job every 72 minutes

你。 提交于 2019-11-27 04:42:12
问题 How would I get a cron job to run every 72 minutes? Or some not so pretty number like that? 回答1: Since cron runs jobs time-based, not interval-based, there's no blindingly simple way to do it. However, although it's a bit of a hack, you can set up multiple lines in crontab until you find the common denominator. Since you want a job to run every 72 minutes, it must execute at the following times: 00:00 01:12 02:24 03:36 04:48 06:00 07:12 ... As you can see, the pattern repeats every 6 hours

Grouping records hour by hour or day by day and filling gaps with zero or null

柔情痞子 提交于 2019-11-26 21:27:32
问题 I have written a query that counts records hour by hour: select TO_CHAR(copied_timestamp, 'YYYY-MM-DD HH24'),count(*) from req group by TO_CHAR(copied_timestamp, 'YYYY-MM-DD HH24'); the result is: 2012-02-22 13 2280 2012-02-22 15 1250 2012-02-22 16 1245 2012-02-22 19 1258 But I need a result like this: 2012-02-22 13 2280 2012-02-22 14 0 2012-02-22 15 1250 2012-02-22 16 1245 2012-02-22 17 0 2012-02-22 18 0 2012-02-22 19 1258 Also I have these queries that group by day and month too! select TO

Regex pattern for HH:MM:SS time string

耗尽温柔 提交于 2019-11-26 18:41:54
I want to parse a hh:mm:ss string. A simple one is ([0-1]?\d|2[0-3]):([0-5]?\d):([0-5]?\d) which expects 2:3:24 or 02:03:24 string. I want to take it a step further and pass the validation even in cases like if you enter just 56, it should be pass, as 56 can be considered as 56 secs [SS] if you enter 2:3 or 02:03 or 02:3 or 2:03 it should pass. 2 minutes and 3 seconds [MM:SS] If you enter 20:30:12 pass with 20 hrs, 30 minutes and 12 secs [HH:MM:SS] if you enter 78:12 , do not pass 78 minutes is wrong.... Basically, if one ":" is found, consider number before ":" as MM and number after ":" as

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

∥☆過路亽.° 提交于 2019-11-26 15:43:57
问题 As I know getHours() , getMinutes() and getSeconds() are all deprecated in Java and they are replaced with Calendar.HOUR_OF_DAY , Calendar.MINUTE , Calendar.SECOND . These will in fact return the hour, minute and second for that particular moment. However, I would want to retrieved the hours and minutes from a Date variable. For instance, say the time retrieved from database is time = Thu Jan 01 09:12:18 CET 1970; int hours = time.getHours(); int minutes = time.getMinutes(); int seconds =

How do I get hour and minutes from NSDate?

谁说我不能喝 提交于 2019-11-26 15:08:18
问题 In my application I need to get the hour and minute separately: NSString *currentHour=[string1 substringWithRange: NSMakeRange(0,2)]; int currentHourInNumber=[currentHour intValue]; Consider string1 contains 11:59:13 AM which is coming from datepicker. Here if I use above code, it's okay to get hour if it's greater than 9. Else I need to change NSMakeRange(0,1) to get hour between 1 to 9. Are there any methods to get the hour, minutes, etc? Thanks in advance, please provide me sample code.

Extracting hours from a DateTime (SQL Server 2005)

孤街浪徒 提交于 2019-11-26 13:04:07
问题 I can extract the month and day by using Day(Date()) , Month(Date()) . I can\'t extract hours, with HOUR(Date()) . I get the following error. \'HOUR\' is not a recognized built-in function name. How can I extract hours? 回答1: SELECT DATEPART(HOUR, GETDATE()); DATEPART documentation 回答2: ... you can use it on any granularity type i.e.: DATEPART(YEAR, [date]) DATEPART(MONTH, [date]) DATEPART(DAY, [date]) DATEPART(HOUR, [date]) DATEPART(MINUTE, [date]) (note: I like the [ ] around the date

Regex pattern for HH:MM:SS time string

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 06:32:11
问题 I want to parse a hh:mm:ss string. A simple one is ([0-1]?\\d|2[0-3]):([0-5]?\\d):([0-5]?\\d) which expects 2:3:24 or 02:03:24 string. I want to take it a step further and pass the validation even in cases like if you enter just 56, it should be pass, as 56 can be considered as 56 secs [SS] if you enter 2:3 or 02:03 or 02:3 or 2:03 it should pass. 2 minutes and 3 seconds [MM:SS] If you enter 20:30:12 pass with 20 hrs, 30 minutes and 12 secs [HH:MM:SS] if you enter 78:12 , do not pass 78

Add 'x' number of hours to date

与世无争的帅哥 提交于 2019-11-26 04:26:24
问题 I currently have php returning the current date/time like so: $now = date(\"Y-m-d H:m:s\"); What I\'d like to do is have a new variable $new_time equal $now + $hours , where $hours is a number of hours ranging from 24 to 800. Any suggestions? 回答1: You may use something like the strtotime() function to add something to the current timestamp. $new_time = date("Y-m-d H:i:s", strtotime('+5 hours')) . If you need variables in the function, you must use double quotes then like strtotime("+{$hours}