datetime-parsing

Parse DateTime string in JavaScript

故事扮演 提交于 2019-11-25 23:35:33
问题 Does anyone know how to parse date string in required format dd.mm.yyyy ? 回答1: See: Mozilla Core JavaScript Reference: Date object Mozilla Core JavaScript Reference: String.Split Code: var strDate = "03.09.1979"; var dateParts = strDate.split("."); var date = new Date(dateParts[2], (dateParts[1] - 1), dateParts[0]); 回答2: If you are using jQuery UI, you can format any date with: <html> <body> Your date formated: <span id="date1"></span><br/> </body> </html> var myDate = '30.11.2011'; var

Parsing ISO-8601 DateTime in java

不打扰是莪最后的温柔 提交于 2019-11-25 22:47:11
I have a trouble with parsing date time in java, I have a strange date time format. How can I parse 2013-04-03T17:04:39.9430000+03:00 date time in java to format dd.MM.yyyy HH:mm in java? The "strange" format in question is ISO-8601 - its very widely used. You can use SimpleDateFormat to reformat it in most way you please: SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); DateTime dtIn = inFormat.parse(dateString}); //where dateString is a date in ISO-8601 format SimpleDateFormat outFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); String dtOut = outFormat.format

How do I translate an ISO 8601 datetime string into a Python datetime object? [duplicate]

允我心安 提交于 2019-11-25 22:37:17
问题 This question already has answers here : How do I parse an ISO 8601-formatted date? (26 answers) Closed 5 years ago . I\'m getting a datetime string in a format like \"2009-05-28T16:15:00\" (this is ISO 8601, I believe). One hackish option seems to be to parse the string using time.strptime and passing the first six elements of the tuple into the datetime constructor, like: datetime.datetime(*time.strptime(\"2007-03-04T21:08:12\", \"%Y-%m-%dT%H:%M:%S\")[:6]) I haven\'t been able to find a \

Parse date string and change format

不羁岁月 提交于 2019-11-25 22:34:39
问题 I have a date string with the format \'Mon Feb 15 2010\'. I want to change the format to \'15/02/2010\'. How can I do this? 回答1: datetime module could help you with that: datetime.datetime.strptime(date_string, format1).strftime(format2) For the specific example you could do >>> datetime.datetime.strptime('Mon Feb 15 2010', '%a %b %d %Y').strftime('%d/%m/%Y') '15/02/2010' >>> 回答2: You can install the dateutil library. Its parse function can figure out what format a string is in without having

How do I parse an ISO 8601-formatted date?

半世苍凉 提交于 2019-11-25 22:18:11
问题 I need to parse RFC 3339 strings like \"2008-09-03T20:56:35.450686Z\" into Python\'s datetime type. I have found strptime in the Python standard library, but it is not very convenient. What is the best way to do this? 回答1: The python-dateutil package can 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