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
4
votes
0 answers

Cannot parse custom date string using ParseExact

I faced with issue related to DateTime.ParseExact. Cannot parse string with 1 digit for month. //this works fine with 2 digits for month DateTime.TryParseExact("030405", "MMddyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date); //this…
user2216
  • 809
  • 1
  • 8
  • 24
4
votes
4 answers

Convert long month name to int

I understand how to use an NSDateFormatter to convert a month component into a long name string, but how does one convert a month name to an int? I've been using a switch statement to convert, but I'm thinking there must be a simpler way. For…
John D.
  • 548
  • 7
  • 19
4
votes
4 answers

Convert string to date in specific format

How do I convert a string to a date type in SQL Server 2008 R2? My string is formatted dd/mm/yyyy I tried this SELECT CAST('01/08/2014' AS DATE) But that does the cast in mm/dd/yyyy format.
Petah
  • 45,477
  • 28
  • 157
  • 213
4
votes
1 answer

Append time to JQuery datepicker?

I'm trying to follow this example in order to append the current time to my input when a date is chosen with the datepicker. According to the example, I should just be able to append my time string in the dateFormat…
lhan
  • 4,585
  • 11
  • 60
  • 105
4
votes
3 answers

Perl equivalent of PHP's strtotime()?

I realize that Perl has strftime, which allows you to pass a formatting object. The functionality I'm wondering if I can find is more like the following (from PHP): $string1 = "Jun 6, 2012"; $string2 = "June 06 2012"; if (strtotime($string1) ==…
NateDSaint
  • 1,524
  • 2
  • 16
  • 35
4
votes
4 answers

How to get Date part from given String?

I have string like this: Mon, 14 May 2012 13:56:38 GMT Now I just want only date i.e. 14 May 2012 What should I need to do for that?
Neha
  • 245
  • 5
  • 17
3
votes
4 answers

How can I parse these strings into UTC dates?

I'm scraping a site, and the dates come in two forms: 11-22-2011 07:41 AM Today @ 07:41 AM Both of these are GMT-8. I'd like to get a unix timestamp out of these, so that I can construct a meaningful date object Any idea what timezone this might…
Eric
  • 95,302
  • 53
  • 242
  • 374
3
votes
2 answers

Parse Chinese DateTime

I'm trying to convert the following string to a DateTimeOffset 二 5月 16 14:41:40 +0800 2023 which translates to "Tue May 16 14:41:40 +0800 2023" I have tried the following code: DateTimeOffset.Parse(lastLogin, new CultureInfo("zh-CN"),…
Bart
  • 75
  • 6
3
votes
3 answers

Joda time timezone parsing with region/city

import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; public class Main { public static void main(String[] args) { System.out.println( …
Maxim Veksler
  • 29,272
  • 38
  • 131
  • 151
3
votes
2 answers

Java Time parse Dates with short day names

I've got the following German date: So, 18 Jul 2021 15:24:00 +0200 I'm unable to parse it using Java Time: DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z", Locale.GERMANY) .parse("So, 18 Jul 2021 15:24:00 +0200", Instant::from) as it…
Niklas
  • 23,674
  • 33
  • 131
  • 170
3
votes
2 answers

Parse Date string to datetime with timezone

I have a string: r = 'Thu Dec 17 08:56:41 CST 2020' Here CST represent China central time('Asia/Shanghai'). I wanted to parse it to datetime...I am doing something like from dateparser import parse r1 = parse(r) Which is giving me r1…
aman jain
  • 63
  • 1
  • 7
3
votes
1 answer

pandas read_csv slow performance when using parse_dates

I have a CSV file with 58K rows of time-series data. The first column is the timestamp and it's all unique values. When I do pd.read_csv("data.csv"), it takes less than a second. But when I do pd.read_csv("data.csv", parse_dates=[0]) it takes more…
empz
  • 11,509
  • 16
  • 65
  • 106
3
votes
2 answers

DateTimeParseException - could not be parsed at index 0

I'm trying to parse the following date "Wed, 26 Feb 2020 03:42:25 -0800" String datePattern = "EEE, dd MMM yyyy HH:mm:ss Z"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(datePattern); ZonedDateTime zonedDateTime =…
vrv67485
  • 31
  • 2
3
votes
3 answers

How to convert string to date correctly?

Why does dateFormatter return the correct date from an invalid format string? let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd" let date = dateFormatter.date(from: "2020/////07////////10") //"Jul 10, 2020 at 12:00 AM"
3
votes
2 answers

Recommended way of parsing dates when presented in a variety of formats

I have a collection of dates as strings entered by users over a period of time. Since these came from humans with little or no validation., the formats entered for the dates varies widely. Below are some examples (the leading numbers are for…
user236520