date

Python / Matplotlib — Histogram of Dates by Day of Year

 ̄綄美尐妖づ 提交于 2020-07-09 03:57:10
问题 I have a list of dates that span several (hundred) years. I'd like to make a histogram that has 366 buckets, one for each day of the year, with the x-axis labelled in a legible way that allows me to see which date is which (I'm expecting a dip for February 29, for example). I've made the following histogram, but easy-to-read X-axis date labels would be awesome. The following code seems cumbersome but gets me what I want (without the X-axis labels): from datetime import date, datetime,

Format date in yyyy-MM-dd hh:mm:ss format from whatever format

感情迁移 提交于 2020-07-08 02:27:14
问题 I am having various date String and want to format in particular format using java String arr[] = {"Jul 02,2020 ","15-10-2015 10:20:56","2015/10/26 12:10:39","27-04-2016 10:22:56","April 7, 2020"}; Arrays.asList(arr).forEach(date->{ try { System.out.println(convertDate(date, "yyyy-MM-dd hh:mm:ss")); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } }); public static String getDateString(String date,String patternStr) throws ParseException { if(StringUtils

UIDatePicker is set to 15 minute intervals, but the date if the user doesn't scroll isn't in 15 minute intervals

最后都变了- 提交于 2020-07-07 06:52:52
问题 I am creating an iOS application that uses two UIDatePickers. They show just hours and minutes (my app still uses the month, day, and year though). In main.storyboard I have set the UIDatePickers' Date values to Current Date. And, I have set their interval to 15 minutes. The issue is that if I don't scroll the UIDatePickers, the date value I get from them isn't in 15 minute intervals. If I scroll them I do get 15 minute intervals. Example: The actual time is 8:47PM. The UIDatePicker loads to

converting a string date into US format in java

主宰稳场 提交于 2020-07-07 03:30:07
问题 I have the below code in which date come as string type and I have to set it in US format so below I have shown it private static final SimpleDateFormat usOutputDate = new SimpleDateFormat("MM/dd/yyyy"); and inside a method I have written the below code and inside dealDateString the value is coming as 02-Mar-2015 // dealDateString = 02-Mar-2015 java.util.Date dealDate = extractDate(dealDateString); //here its value get converted in US format that is 03/02/2015 String dd = usOutputDate.format

converting a string date into US format in java

隐身守侯 提交于 2020-07-07 03:25:32
问题 I have the below code in which date come as string type and I have to set it in US format so below I have shown it private static final SimpleDateFormat usOutputDate = new SimpleDateFormat("MM/dd/yyyy"); and inside a method I have written the below code and inside dealDateString the value is coming as 02-Mar-2015 // dealDateString = 02-Mar-2015 java.util.Date dealDate = extractDate(dealDateString); //here its value get converted in US format that is 03/02/2015 String dd = usOutputDate.format

converting a string date into US format in java

谁都会走 提交于 2020-07-07 03:24:10
问题 I have the below code in which date come as string type and I have to set it in US format so below I have shown it private static final SimpleDateFormat usOutputDate = new SimpleDateFormat("MM/dd/yyyy"); and inside a method I have written the below code and inside dealDateString the value is coming as 02-Mar-2015 // dealDateString = 02-Mar-2015 java.util.Date dealDate = extractDate(dealDateString); //here its value get converted in US format that is 03/02/2015 String dd = usOutputDate.format

ORDER BY date with past dates after upcoming dates

删除回忆录丶 提交于 2020-07-06 09:33:18
问题 I need do execute a query on a table in a MySql database where the order of the resulting rows will be like this: If today is 10/09/12: ... 11/09/12 12/09/12 15/09/12 08/09/12 <--here start the past dates 07/09/12 05/09/12 .... Is there a way to achive this directly in MySQL? I've resolved in this way: First, the select statement include a new boolean that mark if the date is past or future by: SELECT DISTINCT *,CASE WHEN startdate < CURDATE() THEN 0 ELSE 1 END AS past_or_future Second, I've

Why is Date is being returned as type 'double'?

那年仲夏 提交于 2020-07-06 09:24:59
问题 I'm having some trouble working with the as.Date function in R. I have a vector of dates that I'm reading in from a .csv file that are coming in as a factor of integers or as character (depending on how I read in the file, but this doesn't seem to have anything to do with the issue), formatted as %m/%d/%Y . I'm going through the file row by row, pulling out the date field and trying to convert it for use elsewhere using the following code: tmpDtm <- as.Date(as.character(tempDF$myDate), "%m/%d

How do I get the difference between two dates under bash

家住魔仙堡 提交于 2020-07-06 05:53:43
问题 Exactly as the question sounds. I want to subtract say 20120115 from 20120203 and get 19 as the answer. What is the best way to implement this in a shell script? 回答1: let DIFF=(`date +%s -d 20120203`-`date +%s -d 20120115`)/86400 echo $DIFF 回答2: How I solved this is: (hope this eventually contains some more useful stuff) current="$(date +%s.%N)" #current date, precise to nanoseconds old="$(date +%s.%N -d "$(sh some_script_that_gives_a_date.sh)")" #convert to ns too diff=$(echo "$current-$olc"

How do I get yesterday's date in perl?

旧街凉风 提交于 2020-07-05 10:15:14
问题 Currently i take today date using below.I need to get yesterday date using this.. how can i get that ? my $today = `date "+%Y-%m-%d"`; 回答1: If you want yesterday's date: use DateTime qw( ); my $yday_date = DateTime ->now( time_zone => 'local' ) ->set_time_zone('floating') ->truncate( to => 'days' ) ->subtract( days => 1 ) ->strftime('%Y-%m-%d'); For example, in New York, at 2019-05-14 01:00:00, it will give 2019-05-13. For example, in New York, at 2019-11-04 00:00:00, it will give 2019-11-03.