seconds

Convert QDate to seconds

霸气de小男生 提交于 2019-12-02 01:34:15
I take date from QDateTimeEdit and convert it to seconds like this: import time from datetime import datetime date = self.__ui.dateTimeEdit.date().toString("dd/MM/yy") dateString = str(date) seconds = time.mktime(datetime.strptime(dateString, "%d/%m/%y").timetuple()) This works well, but since it looks to long to me, my question is: Is it possible to convert self.__ui.dateTimeEdit.date() directly, without those string conversions? EDIT1 Unfortunately toMSecsSinceEpoch() as falsetru suggested, doesn't work for me. AttributeError: 'QDateTime' object has no attribute 'toMSecsSinceEpoch' I'm using

php - How To Convert 1 day To Seconds

…衆ロ難τιáo~ 提交于 2019-12-01 05:31:32
I am creating a form to set publish interval and want to sum all of the submitted values into seconds. The form consist of fields to determine seconds, minutes, hours, day and so on. I am collecting the submitted values to string by giving date attributes, like second, minute etc. For example: $second second $minute minute $hour hour So if user input 1 in input field to determine the interval in day and 30 in minute , then my code will convert it to string 1 day and 30 minute . My questions: 1- How can I convert 1 day and 30 minute string into seconds so they can be summed up into correct

pandas remove seconds from datetime index

我怕爱的太早我们不能终老 提交于 2019-12-01 04:34:46
I have a pandas dataFrame called 'df' as follows value 2015-09-27 03:58:30 1.0 2015-09-27 03:59:30 1.0 2015-09-27 04:00:30 1.0 2015-09-27 04:01:30 1.0 I just want to strip out the seconds to get this value 2015-09-27 03:58:00 1.0 2015-09-27 03:59:00 1.0 2015-09-27 04:00:00 1.0 2015-09-27 04:01:00 1.0 How can i do this? ive tried things like df.index.to_series().apply(datetime.replace(second=0, microsecond=0)) but i always get errors TypeError: descriptor 'replace' of 'datetime.datetime' object needs an argument You could use datetime.replace to alter the second's attribute as shown: df.index =

In Linux, schedule task to Hour, minute, second precision [duplicate]

↘锁芯ラ 提交于 2019-11-30 23:33:54
This question is an exact duplicate of: Linux task schedule to Hour, minute, second 1 answer I just want to run a shell scrip at say this exact time "16:22:36". utilities like "at" are useless since they don't have "seconds". "sleep" does not work since the loop is ending 8 hours ahead of time for some reason :s , I have searched all over google and couldn't find any tools. so a huge Os like Linux doesn't have a proper task scheduler? The standard cron lacks second precision scheduling because Unix server administration traditionally rarely needed one-second precision It might be used in such

Datetime.now as TimeSpan value?

自古美人都是妖i 提交于 2019-11-30 07:53:35
问题 I need the current Datetime minus myDate1 in seconds. DateTime myDate1 = new DateTime(1970, 1, 9, 0, 0, 00); DateTime myDate2 = DateTime.Now; TimeSpan myDateResult = new TimeSpan(); myDateResult = myDate2 - myDate1; . . I tried different ways to calculate but to no effect. TimeSpan mySpan = new TimeSpan(myDate2.Day, myDate2.Hour, myDate2.Minute, myDate2.Second); . The way it's calculated doesn't matter, the output should just be the difference these to values in seconds. 回答1: Your code is

Convert seconds to Days, Minutes and Seconds

可紊 提交于 2019-11-29 18:50:21
问题 Hey everyone. I've continuing to learn C++ and I've been set the 'challenge' of converting seconds to format as the Days,Minutes and Seconds. For example: 31600000 = 365 days, 46 minutes, 40 seconds. using namespace std; const int hours_in_day = 24; const int mins_in_hour = 60; const int secs_to_min = 60; long input_seconds; cin >> input_seconds; long seconds = input_seconds % secs_to_min; long minutes = input_seconds / secs_to_min % mins_in_hour; long days = input_seconds / secs_to_min /

How to make Java program exit after a couple of seconds

北城以北 提交于 2019-11-29 08:11:00
Is there anyway I can exit a java program after a couple of seconds e.g. 5 seconds. I know you can quit the java program using: System.exit(0); But I'm not sure whether the 0 stands for seconds since this code: System.exit(10); also exits instantly System.exit(0) specifies the exit error code of the program. you can put it on a timer and schedule the task import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class TimedExit { Timer timer = new Timer(); TimerTask exitApp = new TimerTask() { public void run() { System.exit(0); } }; public TimedExit() { timer.schedule

How to get time difference between two timestamps in seconds with jQuery?

此生再无相见时 提交于 2019-11-29 01:37:55
I want to display x seconds ago based on a MySQL Timestamp. I found the plugin called timeago But I cannot find a way to make it display only seconds. I'm OK with 61 seconds, or 300 seconds. Any way to convert the output to seconds with timeago, or with pure jQuery / JavaScript ? Thanks for any help ! Edit: Sample Case : $time1 = "2014-02-02 23:54:04"; // plus PHP ways to format it. //$time2 = NOW() , or date(); whatever. I just want to get how many seconds since $time1 . Edit 2: Working code : <script type="text/javascript"> $(function(){ var d2 = new Date(); var d1 = new Date("2014-02-02 23

PHP — Convert milliseconds to Hours : Minutes : Seconds.fractional

主宰稳场 提交于 2019-11-28 23:39:38
I've got a script that takes in a value in seconds (to 2 decimal points of fractional seconds): $seconds_input = 23.75 I then convert it to milliseconds: $milliseconds = $seconds_input * 1000; // --> 23750 And then I want to format it like so: H:M:S.x // --> 0:0:23.75 Where 'x' is the fraction of the second (however many places after the decimal there are). Any help? I can't seem to wrap my mind around this. I tried using gmdate() but it kept lopping off the fractional seconds. Thanks. Peter Bailey My take function formatSeconds( $seconds ) { $hours = 0; $milliseconds = str_replace( "0.", '',

jQuery: Wait/Delay 1 second without executing code

时光毁灭记忆、已成空白 提交于 2019-11-28 15:41:15
I can't get the .delay method working in jQuery: $.delay(3000); // not working $(queue).delay(3000); // not working I'm using a while loop to wait until an uncontrolled changing value is greater than or equal to another and I can't find any way to hault execution for X seconds. $.delay is used to delay animations in a queue, not halt execution. Instead of using a while loop, you need to recursively call a method that performs the check every second using setTimeout : var check = function(){ if(condition){ // run when condition is met } else { setTimeout(check, 1000); // check again in a second