datetime

PHP: get next date based on fixed base date

安稳与你 提交于 2021-02-05 07:44:28
问题 is there a way in PHP to get the next date(s) using a 4-week interval from a given date ? Example: My start date is Friday, Jan 03, 2014 and my interval is every 4 weeks from that date. What I am looking for is the next date (or dates, if possible) from the current date that matches this 4-week interval. In the above example this would be Friday, May 23, 2014 (then June 20, 2014, July 18, 2014 etc.). I know I can get the current date as follows: $today = date('Y-m-d'); and I could probably

How to get date in UTC format irrespective of current system date with javascript?

折月煮酒 提交于 2021-02-05 07:10:23
问题 I am trying to get the current date in UTC format. SO far I am able to do it but what I am stuck with is that it checks for the current 'System Date' and returns the result. I do not want that to happen because I need it specifically in UTC format and not by getting the system date. Also, the format I have output the result is the one I want with no changes in it. Any suggestions would be of great help. Here is my code: var now = new Date(); var currentDate; var date = (new Date(now) + '')

Calculating time duration from two time values with no date in R

南楼画角 提交于 2021-02-05 06:51:37
问题 I am trying to calculate sleep duration, in hours, from two times self-reported in a diary. I have the bed and wake times in 24-hour format (for bedtimes, for instance, "23:00" is 11PM, "0:00" is midnight, "1:00" is 1AM; for wake times, "9:00" is 9AM). I thought the difftime function would be good to extract the sleep duration, but I am running into an issue with some of the cases. df$duration2<-difftime(df$Waketime2, df$Bedtime2, units="hours") In running the syntax above, it correctly

Calculating time duration from two time values with no date in R

て烟熏妆下的殇ゞ 提交于 2021-02-05 06:50:19
问题 I am trying to calculate sleep duration, in hours, from two times self-reported in a diary. I have the bed and wake times in 24-hour format (for bedtimes, for instance, "23:00" is 11PM, "0:00" is midnight, "1:00" is 1AM; for wake times, "9:00" is 9AM). I thought the difftime function would be good to extract the sleep duration, but I am running into an issue with some of the cases. df$duration2<-difftime(df$Waketime2, df$Bedtime2, units="hours") In running the syntax above, it correctly

How to check for wrong datetime entries (python/pandas)?

杀马特。学长 韩版系。学妹 提交于 2021-02-05 06:47:06
问题 I have an excel dataset containing datetime values of worked hours entered by employees. Now that the end of the year is near they want to report on it, however it is full of wrong entries. Thus I need to clean it. Herebelow some examples of wrong entries. What would be your approach when facing such datasets? I first converted date column to datetime using df['Shiftdatum'] = pd.to_datetime(df.Shiftdatum, format='%Y-%m-%d', errors='coerce') In below's sampledata it shows a NaT How do I filter

django localtime template filter doesn't work

末鹿安然 提交于 2021-02-05 06:43:25
问题 I am use django 1.10 to display datetime. The datetime is stored in mongodb and it is always UTC without timezone info, so I need to display the date time according to machine's time zone which run django. First, add those in settings.py TIME_ZONE = 'Asia/Chongqing' USE_I18N = True USE_L10N = True USE_TZ = True Then in views.py adds: import pytz from tzlocal import get_localzone from django.utils import timezone local_tz = get_localzone() timezone.activate(local_tz) # make datetime object and

select data based on datetime in pandas dataframe

余生长醉 提交于 2021-02-05 06:43:25
问题 I am trying to create some sort of "functional select" that gives users flexibility to create configuration to select data in pandas dataframes. However I ran into some issues that puzzle me. The following is a simplified example: >>> import pandas as pd >>> df = pd.DataFrame({'date': pd.date_range(start='2020-01-01', periods=4), 'val': [1, 2, 3, 4]}) >>> df date val 0 2020-01-01 1 1 2020-01-02 2 2 2020-01-03 3 3 2020-01-04 4 Question 1: Why do I get different result when I apply the function

django localtime template filter doesn't work

北城余情 提交于 2021-02-05 06:43:05
问题 I am use django 1.10 to display datetime. The datetime is stored in mongodb and it is always UTC without timezone info, so I need to display the date time according to machine's time zone which run django. First, add those in settings.py TIME_ZONE = 'Asia/Chongqing' USE_I18N = True USE_L10N = True USE_TZ = True Then in views.py adds: import pytz from tzlocal import get_localzone from django.utils import timezone local_tz = get_localzone() timezone.activate(local_tz) # make datetime object and

day of Year values starting from a particular date

删除回忆录丶 提交于 2021-02-05 06:40:55
问题 I have a dataframe with a date column. The duration is 365 days starting from 02/11/2017 and ending at 01/11/2018. Date 02/11/2017 03/11/2017 05/11/2017 . . 01/11/2018 I want to add an adjacent column called Day_Of_Year as follows: Date Day_Of_Year 02/11/2017 1 03/11/2017 2 05/11/2017 4 . . 01/11/2018 365 I apologize if it's a very basic question, but unfortunately I haven't been able to start with this. I could use datetime(), but that would return values such as 1 for 1st january, 2 for 2nd

day of Year values starting from a particular date

与世无争的帅哥 提交于 2021-02-05 06:40:54
问题 I have a dataframe with a date column. The duration is 365 days starting from 02/11/2017 and ending at 01/11/2018. Date 02/11/2017 03/11/2017 05/11/2017 . . 01/11/2018 I want to add an adjacent column called Day_Of_Year as follows: Date Day_Of_Year 02/11/2017 1 03/11/2017 2 05/11/2017 4 . . 01/11/2018 365 I apologize if it's a very basic question, but unfortunately I haven't been able to start with this. I could use datetime(), but that would return values such as 1 for 1st january, 2 for 2nd