Questions tagged [iso8601]

ISO 8601 is the International Standards Organization's standard for representing time as a string. It covers dates, times, timezones, durations, and many other things.

911 questions
1012
votes
19 answers

Given a DateTime object, how do I get an ISO 8601 date in string format?

Given: DateTime.UtcNow How do I get a string which represents the same value in an ISO 8601-compliant format? Note that ISO 8601 defines a number of similar formats. The specific format I am looking for is: yyyy-MM-ddTHH:mm:ssZ
Iain
  • 12,269
  • 6
  • 24
  • 13
905
votes
29 answers

How do I parse an ISO 8601-formatted date?

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?
Alexander Artemenko
  • 21,378
  • 8
  • 39
  • 36
798
votes
31 answers

Converting ISO 8601-compliant String to java.util.Date

I am trying to convert an ISO 8601 formatted String to a java.util.Date. I found the pattern yyyy-MM-dd'T'HH:mm:ssZ to be ISO8601-compliant if used with a Locale (compare sample). However, using the java.text.SimpleDateFormat, I cannot convert the…
Ice09
  • 8,951
  • 4
  • 23
  • 25
634
votes
15 answers

ISO time (ISO 8601) in Python

I have a file. In Python, I would like to take its creation time, and convert it to an ISO time (ISO 8601) string while preserving the fact that it was created in the Eastern Time Zone (ET). How do I take the file's ctime and convert it to an ISO…
Joseph Turian
  • 15,430
  • 14
  • 47
  • 62
596
votes
11 answers

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

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,…
Andrey Fedorov
  • 9,148
  • 20
  • 67
  • 99
325
votes
16 answers

How do I output an ISO 8601 formatted string in JavaScript?

I have a Date object. How do I render the title portion of the following snippet? A couple days ago I have the "relative time in words" portion from another library. I've tried the following: function…
James A. Rosen
  • 64,193
  • 61
  • 179
  • 261
306
votes
9 answers

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

This docs mention moment.ISO_8601 as a formatting option (from 2.7.0 - http://momentjs.com/docs/#/parsing/special-formats/), but neither of these work (even 2.7.0): var date = moment(); date.format(moment.ISO_8601); // error moment.format(date,…
sennett
  • 8,014
  • 9
  • 46
  • 69
267
votes
13 answers

Python UTC datetime object's ISO format doesn't include Z (Zulu or Zero offset)

Why python 2.7 doesn't include Z character (Zulu or zero offset) at the end of UTC datetime object's isoformat string unlike JavaScript? >>> datetime.datetime.utcnow().isoformat() '2013-10-29T09:14:03.895210' Whereas in javascript >>>…
Murali Mopuru
  • 6,086
  • 5
  • 33
  • 51
262
votes
10 answers

`date` command on OS X doesn't have ISO 8601 `-I` option?

In a Bash script, I want to print the current datetime in ISO 8601 format (preferably UTC), and it seems that this should be as simple as date -I: http://ss64.com/bash/date.html But this doesn't seem to work on my Mac: $ date -I date: illegal option…
Aseem Kishore
  • 10,404
  • 10
  • 51
  • 56
249
votes
14 answers

How can I parse / create a date time stamp formatted with fractional seconds UTC timezone (ISO 8601, RFC 3339) in Swift?

How to generate a date time stamp, using the format standards for ISO 8601 and RFC 3339? The goal is a string that looks like this: "2015-01-01T00:00:00.000Z" Format: year, month, day, as "XXXX-XX-XX" the letter "T" as a separator hour, minute,…
joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
228
votes
4 answers

Illegal pattern character 'T' when parsing a date string to java.util.Date

I have a date string and I want to parse it to normal date use the java Date API,the following is my code: public static void main(String[] args) { String date="2010-10-02T12:23:23Z"; String pattern="yyyy-MM-ddThh:mm:ssZ"; …
hguser
  • 35,079
  • 54
  • 159
  • 293
185
votes
7 answers

How to create a .NET DateTime from ISO 8601 format

I've found how to turn a DateTime into an ISO 8601 format, but nothing on how to do the reverse in C#. I have 2010-08-20T15:00:00Z, and I want to turn it into a DateTime object. I could separate the parts of the string myself, but that seems like a…
Ripter
  • 2,020
  • 2
  • 14
  • 9
131
votes
10 answers

Parsing an ISO8601 date/time (including TimeZone) in Excel

I need to parse an ISO8601 date/time format with an included timezone (from an external source) in Excel/VBA, to a normal Excel Date. As far as I can tell, Excel XP (which is what we're using) doesn't have a routine for that built-in, so I guess I'm…
rix0rrr
  • 9,856
  • 5
  • 45
  • 48
128
votes
2 answers

How to convert Python's .isoformat() string back into datetime object

So in Python 3, you can generate an ISO 8601 date with .isoformat(), but you can't convert a string created by isoformat() back into a datetime object because Python's own datetime directives don't match properly. That is, %z = 0500 instead of 05:00…
Alex Urcioli
  • 2,883
  • 3
  • 11
  • 17
125
votes
12 answers

How do I get an ISO 8601 date on iOS?

It's easy enough to get the ISO 8601 date string (for example, 2004-02-12T15:19:21+00:00) in PHP via date('c'), but how does one get it in Objective-C (iPhone)? Is there a similarly short way to do it? Here's the long way I found to do…
JohnK
  • 6,865
  • 8
  • 49
  • 75
1
2 3
60 61