Questions tagged [rfc3339]

A RFC entitled "Date and Time on the Internet: Timestamps"

See for more details on RFC

RFC 3339 was released in July 2002.

RFC 3339 is a simplification of which excludes durations, week numbers and ordinal days.

Resources:

100 questions
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
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
177
votes
1 answer

What exactly does the T and Z mean in timestamp?

I have this timestamp value being return by a web service "2014-09-12T19:34:29Z" I know that it means timezone, but what exactly does it mean? And I am trying to mock this web service, so is there a way to generate this timestamp using strftime in…
roymustang86
  • 8,054
  • 22
  • 70
  • 101
129
votes
7 answers

How to convert a timezone aware string to datetime in Python without dateutil?

I have to convert a timezone-aware string like "2012-11-01T04:16:13-04:00" to a Python datetime object. I saw the dateutil module which has a parse function, but I don't really want to use it as it adds a dependency. So how can I do it? I have tried…
lxyu
  • 2,661
  • 5
  • 23
  • 29
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
103
votes
3 answers

Parse rfc3339 date strings in Python?

I have a datasets where all the dates have the following format: 2012-10-09T19:00:55Z I'd like to be able to be able to use methods like .weekday on them. How do I convert them to the proper format in Python?
Spearfisher
  • 8,445
  • 19
  • 70
  • 124
89
votes
7 answers

Generate RFC 3339 timestamp in Python

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…
Yarin
  • 173,523
  • 149
  • 402
  • 512
66
votes
4 answers

Convert timestamps with offset to datetime obj using strptime

I am trying to convert time-stamps of the format "2012-07-24T23:14:29-07:00" to datetime objects in python using strptime method. The problem is with the time offset at the end(-07:00). Without the offset i can successfully do time_str =…
auny
  • 1,920
  • 4
  • 20
  • 37
56
votes
8 answers

How do I parse and convert a DateTime to the RFC 3339 date-time format?

How do I convert a DateTime structure to its equivalent RFC 3339 formatted string representation and/or parse this string representation back to a DateTime structure? The RFC-3339 date-time format is used in a number of specifications such as the…
Oppositional
  • 11,141
  • 6
  • 50
  • 63
53
votes
8 answers

Generate an RFC 3339 timestamp similar to Google Tasks API?

I am in the process of building an app that syncs with Google Tasks. As part part of the syncing, I want to compare the local task and the API task, and see which one has been changed more recently. Each task from Google's API contains an updated…
levi
  • 23,693
  • 18
  • 59
  • 73
45
votes
13 answers

Output RFC 3339 Timestamp in Java

I want to output a timestamp with a PST offset (e.g., 2008-11-13T13:23:30-08:00). java.util.SimpleDateFormat does not seem to output timezone offsets in the hour:minute format, it excludes the colon. Is there a simple way to get that timestamp in…
Cristian
  • 42,563
  • 25
  • 88
  • 99
44
votes
2 answers

ISO to datetime object: 'z' is a bad directive

I am trying to convert ISO to datetime using the code below: dt = datetime.datetime.strptime("2013-07-23T15:10:59.342107+01:00", "%Y-%m-%dT%H:%M:%S.%f%z") and I'm getting the error below: 'z' is a bad directive in…
user2667326
  • 505
  • 1
  • 5
  • 7
38
votes
9 answers

How do I parse RFC 3339 datetimes with Java?

I'm trying to parse the date returned as a value from the HTML5 datetime input field. Try it in Opera to see an example. The date returned looks like this: 2011-05-03T11:58:01Z. I'd like to parse that into a Java Date or Calendar Object. Ideally a…
Adam
  • 43,763
  • 16
  • 104
  • 144
36
votes
15 answers

Convert an RFC 3339 time to a standard Python timestamp

Is there an easy way to convert an RFC 3339 time into a regular Python timestamp? I've got a script which is reading an ATOM feed and I'd like to be able to compare the timestamp of an item in the ATOM feed to the modification time of a file. I…
Mark Biek
  • 146,731
  • 54
  • 156
  • 201
33
votes
3 answers

Converting ISO 8601 date time to seconds in Python

I am trying to add two times together. The ISO 8601 time stamp is '1984-06-02T19:05:00.000Z', and I would like to convert it to seconds. I tried using the Python module iso8601, but it is only a parser. Any suggestions?
Zaynaib Giwa
  • 5,366
  • 7
  • 21
  • 26
1
2 3 4 5 6 7