hour

Convert dates to hours

☆樱花仙子☆ 提交于 2019-12-06 15:26:30
问题 I'm trying to work with dates for the first time, I did it something about that with Flash but it's different. I have two different dates and I'd like to see the difference in hours and days with them, I've found too many examples but not what I'm loking for: <?php $now_date = strtotime (date ('Y-m-d H:i:s')); // the current date $key_date = strtotime (date ("2009-11-21 14:08:42")); print date ($now_date - $key_date); // it returns an integer like 5813, 5814, 5815, etc... (I presume they are

Time issues

假装没事ソ 提交于 2019-12-06 15:04:15
问题 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,

Java Swing GUI hour glass

情到浓时终转凉″ 提交于 2019-12-05 17:00:23
There is a JTabbedPane In my Swing program. When user clicks on a tab, the program takes a while to get the data and process the results, then shows the results in the selected tab. How can I display a hour glass, or something of that effect so that user knows it's processing data? Not to click on the tab again before it finishes it job. A JProgressBar (possibly in indetermiante mode) sounds right - put that on the tab until the data has been fetched. A well-designed UI shouldn't force the user to wait for long-running tasks to complete and instead allow them to do something else inbetween.

Calculate number of weeks , days and hours from milliseconds

ε祈祈猫儿з 提交于 2019-12-05 00:08:35
问题 There were many similar questions around but none addressed this calculation. Using javascript i it is easy to find the number of milliseconds diff b/w 2 dates for ex: var mil = Math.floor(new Date("1/1/2012") - new Date("1/7/2012")) mil is assigned 518400000 to get weeks i would do below var weeks = mil / (1000*7*24*60*60); in the above example it exactly fits 1 week. For other possible inputs i would like to get output as ex: n Weeks, y days , z hours So i did mil % (1000*7*24*3600) to get

jQuery - Change 1-24 hour to 1-12 hour using .getHours() method?

五迷三道 提交于 2019-12-02 14:48:22
问题 Fiddle: http://jsfiddle.net/bnsex/1/ I want to use 12 hour clock for this code... $(document).ready(function() { setInterval( function() { var hours = new Date().getHours(); $(".hours, .hour").html(( hours < 10 ? "0" : "" ) + hours); }, 1000); }); ​ Your help is much appreciated :D 回答1: You can achieve this using the modulus % operator, which finds the remainder of a division operation. For example, 11 % 12 and 23 % 12 both equal 11, like a 12-hour clock would portray. var hours = new Date()

jQuery - Change 1-24 hour to 1-12 hour using .getHours() method?

只谈情不闲聊 提交于 2019-12-02 08:22:09
Fiddle: http://jsfiddle.net/bnsex/1/ I want to use 12 hour clock for this code... $(document).ready(function() { setInterval( function() { var hours = new Date().getHours(); $(".hours, .hour").html(( hours < 10 ? "0" : "" ) + hours); }, 1000); }); ​ Your help is much appreciated :D You can achieve this using the modulus % operator, which finds the remainder of a division operation. For example, 11 % 12 and 23 % 12 both equal 11, like a 12-hour clock would portray. var hours = new Date().getHours() % 12; if (hours == 0) { hours += 12; } http://jsfiddle.net/ph7Vf/ Try with this: hours = (hours <

Get all full hours of every day of a year

两盒软妹~` 提交于 2019-12-01 21:20:03
I need to get / print on command line every full hour of every day of a given year, e.g. 2011 but I am struggling to code it in Java. Has anybody ever coded this issue? This should work: final DateFormat df = DateFormat.getDateTimeInstance(); final Calendar c = Calendar.getInstance(); c.clear(); for (c.set(2011, Calendar.JANUARY, 1, 0, 0, 0); c.get(Calendar.YEAR) == 2011; c.add(Calendar.HOUR_OF_DAY, 1)) System.out.println(df.format(c.getTime())); Notice, for example, this subtlety in the output: Oct 30, 2011 12:00:00 AM Oct 30, 2011 1:00:00 AM Oct 30, 2011 2:00:00 AM Oct 30, 2011 2:00:00 AM

Extracting 2 digit hour from POSIXct in R

泄露秘密 提交于 2019-12-01 10:34:05
I would like to extract the hour from a POSIXct time in R, but retrieve the 2 digit answer. For example, test=as.POSIXct("2015-03-02 03:15:00") test [1] "2015-01-02 03:15:00 GMT" month(testing) [1] 1 hour(testing) [1] 3 The results give the relevant month and hour, but I would like to see 01 and 03 instead of just 1 and 3 . Try to do this: strftime(test, format="%H") to extract hours and strftime(test, format="%m") for month 来源: https://stackoverflow.com/questions/35227648/extracting-2-digit-hour-from-posixct-in-r

extract hour from timestamp with python

瘦欲@ 提交于 2019-12-01 03:54:10
I have a dataframe df_energy2 df_energy2.info() <class 'pandas.core.frame.DataFrame'> RangeIndex: 29974 entries, 0 to 29973 Data columns (total 4 columns): TIMESTAMP 29974 non-null datetime64[ns] P_ACT_KW 29974 non-null int64 PERIODE_TARIF 29974 non-null object P_SOUSCR 29974 non-null int64 dtypes: datetime64[ns](1), int64(2), object(1) memory usage: 936.8+ KB with this structure : df_energy2.head() TIMESTAMP P_ACT_KW PERIODE_TARIF P_SOUSCR 2016-01-01 00:00:00 116 HC 250 2016-01-01 00:10:00 121 HC 250 Is there any python fucntion which can extract hour from TIMESTAMP ? Kind regards I think you

extract hour from timestamp with python

孤人 提交于 2019-12-01 01:24:57
问题 I have a dataframe df_energy2 df_energy2.info() <class 'pandas.core.frame.DataFrame'> RangeIndex: 29974 entries, 0 to 29973 Data columns (total 4 columns): TIMESTAMP 29974 non-null datetime64[ns] P_ACT_KW 29974 non-null int64 PERIODE_TARIF 29974 non-null object P_SOUSCR 29974 non-null int64 dtypes: datetime64[ns](1), int64(2), object(1) memory usage: 936.8+ KB with this structure : df_energy2.head() TIMESTAMP P_ACT_KW PERIODE_TARIF P_SOUSCR 2016-01-01 00:00:00 116 HC 250 2016-01-01 00:10:00