How to convert Python’s .isoformat() string back into datetime object [duplicate]

Python 3.7+ As of Python 3.7 there is a method datetime.fromisoformat() which is exactly the reverse for isoformat(). Older Python If you have older Python, then this is the current best “solution” to this question: pip install python-dateutil Then… import datetime import dateutil def getDateTimeFromISO8601String(s): d = dateutil.parser.parse(s) return d

How do I format a date as ISO 8601 in moment.js?

moment().toISOString(); // or format() – see below http://momentjs.com/docs/#/displaying/as-iso-string/ Update Based on the answer: by @sennet and the comment by @dvlsg (see Fiddle) it should be noted that there is a difference between format and toISOString. Both are correct but the underlying process differs. toISOString converts to a Date object, sets to UTC then uses the … Read more

Annoying javascript timezone adjustment issue

Everything is fine, try this: new Date(Date.parse(“2011-10-02T23:00+02:00”)).getUTCHours() //21 The date is parsed correctly (taking the timezone into account as expected). However when you simply print Date.toString() it shows the date in current browser timezone (one of the sins of Java Date object shamelessly copied to JavaScript…) If you stick to getUTC*() family of methods you … Read more

How to calculate Date from ISO8601 week number in Java

UPDATE: The concepts presented here still apply, but the code is outmoded. The Joda-Time project, now in maintenance mode, advises migration to the java.time classes. See the java.time code in the Answer by Szulc. Short Answer DateTime dateTimeStart = new DateTime( “2003-W01-1”, DateTimeZone.UTC ); // Joda-Time 2.4. DateTime dateTimeStop = dateTimeStart.plusWeeks( 1 ); For details, … Read more

Java Time Zone When Parsing DateFormat

tl;dr OffsetDateTime.parse( “2010-12-27T10:50:44.000-08:00” ) ISO 8601 The input string format is defined in the ISO 8601 standard, a family of date-time formats. Avoid old date-time classes The Question and other Answers use old outmoded date-time classes bundled with the earliest versions of Java. Avoid them. Now supplanted by the java.time classes. Using java.time Your input … Read more

How to parse an ISO-8601 duration in Objective C?

Swift3,4,5 implementation: https://github.com/Igor-Palaguta/YoutubeEngine/blob/master/Source/YoutubeEngine/Parser/NSDateComponents%2BISO8601.swift Example: let components = try DateComponents(ISO8601String: “P1Y2M3DT4H5M6S”) Tests: https://github.com/Igor-Palaguta/YoutubeEngine/blob/master/Tests/YoutubeEngineTests/ISO8601DurationTests.swift Update: fixed for DougSwith case “P3W3DT20H31M21”

What is the motivation for two different week-based-year definitions in JSR-310?

This is a bug in IsoFields which managed to slip through because this method was untested (sorry about that). There should be very little observable difference between IsoFields and WeekFields.ISO when implemented correctly. See the bug report and patch which will eventually work through the system and be fixed. Note, testing revealed that getting the … Read more