How do I parse an ISO 8601-formatted date and time?

isoparse function from python-dateutil The python-dateutil package has dateutil.parser.isoparse to parse not only RFC 3339 datetime strings like the one in the question, but also other ISO 8601 date and time strings that don’t comply with RFC 3339 (such as ones with no UTC offset, or ones that represent only a date). >>> import dateutil.parser … Read more

Converting ISO 8601 date time to seconds in Python

If you want to get the seconds since epoch, you can use python-dateutil to convert it to a datetime object and then convert it so seconds using the strftime method. Like so: >>> import dateutil.parser as dp >>> t=”1984-06-02T19:05:00.000Z” >>> parsed_t = dp.parse(t) >>> t_in_seconds = parsed_t.timestamp() >>> t_in_seconds ‘455051100’ So you were halfway there … Read more

Convert ISO 8601 duration with JavaScript

You could theoretically get an ISO8601 Duration that looks like the following: P1Y4M3W2DT10H31M3.452S I wrote the following regular expression to parse this into groups: (-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)? It’s not pretty, and someone better versed in regular expressions might be able to write a better one. The groups boil down into the following: Sign Years Months Weeks Days … Read more

Java 8 Date and Time: parse ISO 8601 string without colon in offset [duplicate]

If you want to parse all valid formats of offsets (Z, ±hh:mm, ±hhmm and ±hh), one alternative is to use a java.time.format.DateTimeFormatterBuilder with optional patterns (unfortunatelly, it seems that there’s no single pattern letter to match them all): DateTimeFormatter formatter = new DateTimeFormatterBuilder() // date/time .append(DateTimeFormatter.ISO_LOCAL_DATE_TIME) // offset (hh:mm – “+00:00” when it’s zero) .optionalStart().appendOffset(“+HH:MM”, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)