iso8601

How to format an UTC date to use the Z (Zulu) zone designator in php?

折月煮酒 提交于 2019-11-26 15:58:18
问题 I need to display and handle UTC dates in the following format: 2013-06-28T22:15:00Z As this format is part of the ISO8601 standard I have no trouble creating DateTime objects from strings like the one above. However I can't find a clean way (meaning no string manipulations like substr and replace, etc.) to present my DateTime object in the desired format. I tried to tweak the server and php datetime settings, with little success. I always get: $date->format(DateTime::ISO8601); // gives 2013

How to calculate Date from ISO8601 week number in Java

廉价感情. 提交于 2019-11-26 14:37:49
问题 Is there any way of doing this: How to get dates of a week (I know week number)? for ISO 8601 week number without using any library or calender in Java? 回答1: 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

Does Javascript/EcmaScript3 support ISO8601 date parsing?

泄露秘密 提交于 2019-11-26 14:28:52
问题 How are you currently parsing ISO8601 dates e.g. 2010-02-23T23:04:48Z in JavaScript? Some browsers return NaN (including Chrome) when using the code below, FF3.6+ works though. <html> <body> <script type="text/javascript"> var d = Date.parse("2010-02-23T23:04:48Z"); document.write(d); </script> </body> </html> You can try this here http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_parse 回答1: Try this: http://anentropic.wordpress.com/2009/06/25/javascript-iso8601-parser-and-pretty

Java SimpleDateFormat for time zone with a colon separator?

笑着哭i 提交于 2019-11-26 12:54:14
I have a date in the following format: 2010-03-01T00:00:00-08:00 I have thrown the following SimpleDateFormats at it to parse it: private static final SimpleDateFormat[] FORMATS = { new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"), //ISO8601 long RFC822 zone new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"), //ISO8601 long long form zone new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"), //ignore timezone new SimpleDateFormat("yyyyMMddHHmmssZ"), //ISO8601 short new SimpleDateFormat("yyyyMMddHHmm"), new SimpleDateFormat("yyyyMMdd"), //birthdate from NIST IHE C32 sample new SimpleDateFormat("yyyyMM"),

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

安稳与你 提交于 2019-11-26 12:42:49
问题 I\'m looking for an easy way to parse a string that contains an ISO-8601 duration in Objective C. The result should be something usable like a NSTimeInterval . An example of an ISO-8601 duration: P1DT13H24M17S , which means 1 day, 13 hours, 24 minutes and 17 seconds. 回答1: If you know exactly which fields you'll be getting, you can use one invocation of sscanf() : const char *stringToParse = ...; int days, hours, minutes, seconds; NSTimeInterval interval; if(sscanf(stringToParse, "P%dDT%dH%dM

How can I convert a date value in ISO 8601 format to a date object in JavaScript?

怎甘沉沦 提交于 2019-11-26 11:21:36
问题 I\'ve been trying to convert a date value into a more readable format. To do that, I\'m trying to parse the date using the JavaScript Date.parse() method. That however does not work on the input (eg: \"2007-09-21T14:15:34.058-07:00\" ) that I have. The end goal is to output a date string like \"January 30th, 2008 @ 2:15PM\" . Any ideas? 回答1: Try http://www.datejs.com/. It is a JavaScript Date Library with an extended Date.parse method and a Date.parseExact method, which lets you specify a

Regex and ISO8601 formatted DateTime [duplicate]

只愿长相守 提交于 2019-11-26 10:57:56
问题 This question already has answers here : Regex validate correct ISO8601 date string with time (6 answers) Closed 2 months ago . I have a DateTime string ISO8601 formated 2012-10-06T04:13:00+00:00 and the following Regex which does not match this string #(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2})\\:(\\d{2})\\:(\\d{2})\\+(\\d{2})\\:(\\d{2})# I can\'t figure out why it does not match. I escaped metacharacters, for me it seems to be OK. http://jsfiddle.net/5n5vk/2/ EDIT : The right way: http://jsfiddle

Generate RFC 3339 timestamp in Python

白昼怎懂夜的黑 提交于 2019-11-26 09:35:06
问题 I\'m trying to generate an RFC 3339 UTC timestamp in Python. So far I\'ve been able to do the following: >>> d = datetime.datetime.now() >>> print d.isoformat(\'T\') 2011-12-18T20:46:00.392227 My problem is with setting the UTC offset. According to the docs, the classmethod datetime.now([tz]) , takes an optional tz argument where tz must be an instance of a class tzinfo subclass , and datetime.tzinfo is an abstract base class for time zone information objects. This is where I get lost- How

ISO 8601 String to Date/Time object in Android

别说谁变了你拦得住时间么 提交于 2019-11-26 08:27:10
I have a string in standard ISO 8601 format that contains the date/time returned from a web service like so: String dtStart = "2010-10-15T09:27:37Z" How do I get this into an object such as Time or Date? I initially want to output it in a different format, but will need to do other stuff with it later (i.e. maybe use in a different format). Cheers Seitaridis String dtStart = "2010-10-15T09:27:37Z"; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); try { Date date = format.parse(dtStart); System.out.println(date); } catch (ParseException e) { // TODO Auto-generated

Cannot parse String in ISO 8601 format, lacking colon in offset, to Java 8 Date

百般思念 提交于 2019-11-26 07:44:28
问题 I\'m a little bit frustrated of java 8 date format/parse functionality. I was trying to find Jackson configuration and DateTimeFormatter to parse \"2018-02-13T10:20:12.120+0000\" string to any Java 8 date, and didn\'t find it. This is java.util.Date example which works fine: Date date = new SimpleDateFormat(\"yyyy-MM-dd\'T\'hh:mm:ss.SSSZZZ\") .parse(\"2018-02-13T10:20:12.120+0000\"); The same format doesn\'t work with new date time api ZonedDateTime dateTime = ZonedDateTime.parse(\"2018-02