hour

Time issues

自闭症网瘾萝莉.ら 提交于 2019-12-01 00:57:47
I am facing some problems in a cross platform program : when I open a python shell in Linux and in Windows, I don't get the same time from the Epoch. In Linux, I tried to do dpkg-reconfigure tzdata . Currently, in linux I get that avec the dpkg-reconfigure tzdata : Current default time zone: 'Europe/London' Local time is now: Mon May 30 10:29:52 BST 2011. Universal Time is now: Mon May 30 09:29:52 UTC 2011. Then, in the python console, I create this script : import time print time.tzname, time.timezone, time.altzone, time.daylight print time.localtime() print time.localtime(0) On linux that

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

回眸只為那壹抹淺笑 提交于 2019-11-30 14:52:12
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_CHAR(copied_timestamp, 'YYYY-MM-DD'),count(*) from req group by TO_CHAR(copied_timestamp, 'YYYY-MM-DD')

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

给你一囗甜甜゛ 提交于 2019-11-29 21:42:22
问题 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

Changing the 1-24 hour to 1-12 hour for the “getHours()” Method

十年热恋 提交于 2019-11-29 03:12:05
When I use the "getHour()" method in javascript, it displays the military time format. I need it to display the hour in numbers between 1-12 instead. Can anybody tell me how to do this? Here is the code I am using: function updateclock() { var time = new Date(); var todisplay = ''; if (time.getHours() < 10) todisplay += time.getHours(); else todisplay += time.getHours(); if (time.getMinutes() < 10) todisplay += ':0' + time.getMinutes(); else todisplay += ':' + time.getMinutes(); document.getElementById("clock").innerHTML = todisplay; } Why not do it the brief way? Math, people! :) // returns

How to know if now time is between two hours?

和自甴很熟 提交于 2019-11-29 01:26:43
I have a now time: new Date(); And I have some hour constants, for example, 23 and 8 (it's 11pm or 23:00, 8am or 08:00). How I can know is now time between it's two hour constants? It need to run some code of program or not to run if now time is between in two hours, for example, do not run some code if its already evening and while it is not a morning. Here the image to better explain: Some situations when silent mode does not fire: 00:00 20.06.13 - 23:00 20.06.13 // after 23.00 can loud!! 23:00 20.06.13 - 15:00 20.06.13 // after 15.00 can loud!! 01:00 20.06.13 - 08:00 20.06.13 // after 08.00

Subtract n hours from a DateTime in Ruby

我只是一个虾纸丫 提交于 2019-11-28 21:03:26
I have a Ruby DateTime which gets filled from a form. Additionally I have n hours from the form as well. I'd like to subtract those n hours from the previous DateTime. (To get a time range). DateTime has two methods "-" and "<<" to subtract day and month, but not hour. ( API ). Any suggestions how I can do that? You could do this. adjusted_datetime = (datetime_from_form.to_time - n.hours).to_datetime You can just subtract less than one whole day: two_hours_ago = DateTime.now - (2/24.0) This works for minutes and anything else too: hours = 10 minutes = 5 seconds = 64 hours = DateTime.now -

How to do a cron job every 72 minutes

爷,独闯天下 提交于 2019-11-27 23:37:10
How would I get a cron job to run every 72 minutes? Or some not so pretty number like that? 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 with 5 jobs. So, you will have 5 lines in your crontab : 0 0,6,12,18 * * * command 12 1,7,13,19 * * * command

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

纵饮孤独 提交于 2019-11-27 23:17:16
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_CHAR(copied_timestamp, 'YYYY-MM-DD'),count(*) from req group by TO_CHAR(copied_timestamp, 'YYYY-MM-DD')

Changing the 1-24 hour to 1-12 hour for the “getHours()” Method

走远了吗. 提交于 2019-11-27 17:26:29
问题 When I use the "getHour()" method in javascript, it displays the military time format. I need it to display the hour in numbers between 1-12 instead. Can anybody tell me how to do this? Here is the code I am using: function updateclock() { var time = new Date(); var todisplay = ''; if (time.getHours() < 10) todisplay += time.getHours(); else todisplay += time.getHours(); if (time.getMinutes() < 10) todisplay += ':0' + time.getMinutes(); else todisplay += ':' + time.getMinutes(); document

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

依然范特西╮ 提交于 2019-11-27 11:44:46
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 = time.getSeconds(); By retrieving the hours, minutes, and seconds, I get hours = 9 minutes = 12 seconds =