Questions tagged [date-parsing]

Date-parsing refers to programming logic which reads one or more parameters, attempts to match it to a supported or specified date format, then returns the resulting Date if successful.

References

494 questions
1
vote
0 answers

Calculating if it's less than 24 hours between two dates and times in a string but I get an error java.time.format.DateTimeParseException:

Im trying to calculate two dates in a string if its less than 24 hours but I get an error: java.time.format.DateTimeParseException: Text '20 4 01:40 AM' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {DayOfMonth=20,…
Tamara
  • 47
  • 1
  • 8
1
vote
3 answers

strtotime() fails to parse "00:20 AM" in datetime string

I want to format a date for SQL, but I am getting an unexpected result: echo date('Y-m-d H:i:s', strtotime("February 13 2022 10:08 PM")); //2022-02-13 22:08:00 echo date('Y-m-d H:i:s', strtotime("March 23 2022 00:20 AM")); //1970-01-01 00:00:00 How…
Dumitru
  • 116
  • 1
  • 8
1
vote
2 answers

Pandas date parsing from CSV file

I have one csv file: year;month;day;hour;min;sec;temperature 2022;10;27;13;36;42;5.835 2022;10;27;14;36;42;6.435 2022;10;27;15;36;42;6.335 2022;10;27;16;36;42;6.435 And I would like to plot a simple graph from it. I am not able to combine separate…
fred
  • 93
  • 8
1
vote
1 answer

Golang parsing date in RFC822Z format without leading zero

I have a date string I can't control that I'm trying to parse into a Date. The format most closely resembles RFC822Z. RFC822Z = "02 Jan 06 15:04 -0700" Reference: https://yourbasic.org/golang/format-parse-string-time-date-example/ However, it does…
vbp13
  • 1,040
  • 1
  • 10
  • 20
1
vote
1 answer

Java OffsetDateTime cannot be parsed

I want to parse the following String into an OffsetDateTime: OffsetDateTime test = OffsetDateTime.parse("2021-12-31T23:00:00.000+00:00"); However, this results in an exception: java.time.format.DateTimeParseException: Text…
1
vote
1 answer

DateTime javascript is showing NAN only for some users

I have a DateTime in c # code that I'm trying to convert it in a string before sending it to the front end. For example, I have this C#: DateTime utcN = DateTime.UtcNow; string utcNow = utcN.ToString(); //an example "12/31/2099 12:00:00 AM" And…
Ser
  • 13
  • 3
1
vote
1 answer

parsing date in php

I need to be able to compare some month names I have in an array. It would be nice if there were some direct way or sample of it.. I have this code but i dont know how to parse the given condition (the month).. I don't know what code to use to…
Alvin Jorge
  • 87
  • 2
  • 10
1
vote
1 answer

ParseExact - FormatException: String was not recognized as a valid DateTime

Here's my code # $index is 12 (for exif 'date taken') $value = $dir.GetDetailsof($file, $index) $value = $value.Trim() if ($value -and $value -ne '') { return [DateTime]::ParseExact($value, "g", $null) } return $null this always throws the…
mccrispy
  • 11
  • 4
1
vote
2 answers

How to parse date from year and quarter using java.time

I am trying to parse strings in the format of " " ("2022 1", "2022 2") into java.time.LocalDate objects. The closest related question I could find is this, but there the author also has the month. If I try to use DateTimeFormatter…
1
vote
1 answer

Date Entity Parsing Incorrect Year for Incomplete Dates

I have a dataset (df_test) containing of several news articles (Text_4). Using SpaCy, I've extracted the 'DATE' entities. For those I want to see whether they are in the future or in the past (to identify news articles that reference future events…
AlexanderP
  • 126
  • 6
1
vote
1 answer

Datefinder.find_dates throws out dates for any number in the text, but "strict=True" does not work

I am trying to pull dates from news and government announcement texts I have scraped on Covid-19 in Hawaii. I have run a sample program on a dummy data set, and find dates generated for every number on the page. When I use "strict=True" there are…
1
vote
3 answers

Format and parsing same date provides different result

Could anybody please tell me why I'm getting "10/09/2022" on the console? String sFecha = "10/21/2021"; try { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); System.out.println(sdf.format(sdf.parse(sFecha))); } catch…
1
vote
1 answer

MySQL datetime filed: Truncated incorrect datetime value

I am trying to convert string to mysql datetime format. using below format. but tis giving Truncated incorrect datetime value message. following this page format…
sfgroups
  • 18,151
  • 28
  • 132
  • 204
1
vote
0 answers

how does a natural language date parser work?

can someone explain quickly what are the steps that a natural language parser executes to achieve its work? are the steps the same regardless of language to translate or the language determines the way of translating? Does exist some multilanguage…
pinale
  • 2,060
  • 6
  • 38
  • 72
1
vote
4 answers

How to check date if its 12 hour format or 24 hour format in PHP?

I want to check the date input and convert it to 24h format. For example the datetime is: $date="2021-02-5 11:45:00 AM" and after i check it with this condition: if (preg_match("/am|pm|AM|PM/", $date)) { $date=date('Y-m-d…
msanli224
  • 41
  • 1
  • 9