time

How can I print every minute using Datetime with Python

荒凉一梦 提交于 2021-01-28 05:02:05
问题 As an example, I want to print, "1 min", every time 1 minute has passed using time or datetime. I cant use time.sleep(60) because I have more code that needs to run in the whileloop every update. I need a way to check if datetime.now() is greater than 1 minute ago. Thanks! import time import datetime as dt t = dt.datetime.now() while True: if 60 seconds has passed: print("1 Min") 回答1: This may be what you are looking for: import datetime as dt from time import sleep t = dt.datetime.now()

Different timezone in Google Colab

核能气质少年 提交于 2021-01-28 02:08:14
问题 Question: Why does the timezone in Colab different from local timezone? Background: : I'm living in US. But the there is a five hours difference between the Colab time (I specify the US timezone) and local time. Code: !rm /etc/localtime !ln -s /usr/share/zoneinfo/US /etc/localtime # the time should be around 11:20 !date Results: Wed Aug 7 16:20:40 UTC 2019 回答1: You can change the timezone in two steps: Step 1: Find the name of your timezone in the hierarchy !ls -al /usr/share/zoneinfo/ For US

Current Time (Javascript) In HTML

蹲街弑〆低调 提交于 2021-01-28 00:24:58
问题 Hi currently I had a javascript that display current time. Is a example taken from the internet. How do I go about doing it such that the current time displayed is 5mins behind the actual time. Don't really know how the time works. Tried to change some numbers but to no avail. Currently this is the code. $(document).ready(function() { var MONTHS = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], DAYS = ["Sunday",

Get the local time from a UTC time

懵懂的女人 提交于 2021-01-27 23:46:12
问题 Let's say I have a data set with the date, latitude, and longitude. dt = data.table(date = c("2017-10-24 05:01:05", "2017-10-24 05:01:57", "2017-10-24 05:02:54"), lat = c(-6.2704925537109375, -6.2704925537109375, -6.2704925537109375), long = c(106.5803680419922, 106.5803680419922, 106.5803680419922)) The time is UTC. Is it possible to transfer that UTC to the local time using the lat and long? 回答1: I found a good answer on converting longitude and latitude to timezones here, so here is how we

increase php max_execution_time in IIS 7.5

寵の児 提交于 2021-01-27 21:54:56
问题 I'm trying to increase the max_execution_time value in PHP(5.5) running on IIS 7.5 (Windows Server 2012). phpinfo() shows max_execution_time=300 regardless of what I tried. Some Internet sources mentioned that this value is overridden by something in IIS. Based on Internet searches, I've tried the following: Edited max_execution_time in php.ini to 1200 then restarted server - no effect Changed CGI->Behavior->Time-out to 1200 then restarted server - no effect Put "ini_set('max_execution_time',

How to provide window of time for input(), let program move on if not used

▼魔方 西西 提交于 2021-01-27 19:42:36
问题 what I have is import time r = 0 while True: print(r) r += 1 time.sleep(3) number = input() num = int(number) #???????????? if num == r: print('yes') else: print('no') And what I want to do is make it so after every number printed there's a 3 second window for the user to input the value of r, and if the user does nothing then have the program move on. How do I do that? 回答1: Here is a working code using signal and Python 3.6+ That should run under any Unix & Unix-like systems and will fail

Selenium Python - Explicit waits not working

*爱你&永不变心* 提交于 2021-01-27 19:04:36
问题 I am unable to get explicit waits to work while waiting for the page to render the js, so I am forced to use time.sleep() in order for the code to work as intended. I read the docs and still wasn't able to get it to work. http://selenium-python.readthedocs.io/waits.html The commented out section of code with the time.sleep() works as intended. The WebDriverWait part runs but does not wait. from selenium import webdriver import time from selenium.webdriver.support.ui import WebDriverWait from

Calculating mean and sd of bedtime (hh:mm) in R - problem are times before/after midnight

自作多情 提交于 2021-01-27 18:21:33
问题 I got the following dataset: data <- read.table(text=" wake_time sleep_time 08:38:00 23:05:00 09:30:00 00:50:00 06:45:00 22:15:00 07:27:00 23:34:00 09:00:00 23:00:00 09:05:00 00:10:00 06:40:00 23:28:00 10:00:00 23:30:00 08:10:00 00:10:00 08:07:00 00:38:00", header=T) I used the chron-package to calculate the average wake_time: > mean(times(data$wake_time)) [1] 08:20:12 But when I do the same for the variable sleep_time, this happens: > mean(times(data$sleep_time)) [1] 14:04:00 I guess the

PHP: Time difference (min:sec:tenths)

霸气de小男生 提交于 2021-01-27 18:00:32
问题 How can I calculate time difference when operating with minutes:seconds.tenth ? For example how can I achieve this example: 40:24.5 - 67:52.4 = -27:27.9 I was going to use this but then discovered lack of tenths: $time1 = new date('40:24.5'); $time2 = new date('67:52.4'); $interval = $time1->diff($time2); echo $interval->format('%R%%i:%s:??'); 回答1: Like you already "tried", you can use DateTime extension: function time_difference($t1, $t2) { $t1 = DateTime::createFromFormat('i:s.u', $t1, new

Time duration to string 2h instead 2h0m0s

落爺英雄遲暮 提交于 2021-01-27 12:20:44
问题 The default time.Duration String method formats the duration with adding 0s for minutes and 0m0s for hours. Is there function that I can use that will produce 5m instead 5m0s and 2h instead 2h0m0s ... or I have to implement my own? 回答1: Foreword: I released this utility in github.com/icza/gox, see timex.ShortDuration(). Not in the standard library, but it's really easy to create one: func shortDur(d time.Duration) string { s := d.String() if strings.HasSuffix(s, "m0s") { s = s[:len(s)-2] } if