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.
Questions tagged [iso8601]
911 questions
116
votes
6 answers
How to output date in javascript in ISO 8601 without milliseconds and with Z
Here is a standard way to serialise date as ISO 8601 string in JavaScript:
var now = new Date();
console.log( now.toISOString() );
// outputs '2015-12-02T21:45:22.279Z'
I need just the same output, but without milliseconds. How can I output…

bessarabov
- 11,151
- 10
- 34
- 59
109
votes
6 answers
ISO-8601 String to Date in Google Sheets cell
I have a bunch of ISO-8601 formatted strings in a column of my sheet. How can I get google sheets to treat them as Dates so I can do math on them (difference in minutes between two cells, for example)? I tried just…

Bob Kuhar
- 10,838
- 11
- 62
- 115
95
votes
3 answers
What does 'PT' prefix stand for in Duration?
I am trying to use the Duration class instead of long.
It has superior literal syntax. I like its flexibility, though it looks weird.
"PT10S" means 10 seconds, what is the problem to accept "10 seconds"?!
Okay never mind.
I am just curious why PT…

Daniil Iaitskov
- 5,525
- 8
- 39
- 49
94
votes
5 answers
Parsing ISO 8601 date in JavaScript
I need help/tips on converting an ISO 8601 date with the following structure into JavaScript:
CCYY-MM-DDThh:mm:ssTZD
I'd like to format the date like so:
January 28, 2011 - 7:30PM EST
I'd like to keep this solution as clean and minimal as…

Slythic
- 1,853
- 2
- 15
- 14
93
votes
12 answers
Regex to match an ISO 8601 datetime string
does anyone have a good regex pattern for matching iso datetimes?
ie: 2010-06-15T00:00:00

Scott Klarenbach
- 37,171
- 15
- 62
- 91
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
80
votes
2 answers
Python - Convert string representation of date to ISO 8601
In Python, how can I convert a string like this:
Thu, 16 Dec 2010 12:14:05 +0000
to ISO 8601 format, while keeping the timezone?
Please note that the orginal date is string, and the output should be string too, not datetime or something like…

Alon Gubkin
- 56,458
- 54
- 195
- 288
76
votes
6 answers
How to format an UTC date to use the Z (Zulu) zone designator in php?
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…

sallaigy
- 1,524
- 1
- 13
- 12
74
votes
8 answers
Sort Array by ISO 8601 date
How can I sort this array by date (ISO 8601)?
var myArray = new Array();
myArray[0] = { name:'oldest', date:'2007-01-17T08:00:00Z' }
myArray[1] = { name:'newest', date:'2011-01-28T08:00:00Z' }
myArray[2] = { name:'old', …

Peter
- 11,413
- 31
- 100
- 152
72
votes
11 answers
Java SimpleDateFormat for time zone with a colon separator?
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…

Freiheit
- 8,408
- 6
- 59
- 101
67
votes
8 answers
Format date in MySQL SELECT as ISO 8601
I'm trying to grab the date from my database in a standard timestamp and display it as ISO 8601. I'm unable to easily do it in PHP so I'm trying to do it in my SELECT statement. This is what I have, but it displays an error:
SELECT * FROM…

Adam
- 9,189
- 15
- 46
- 62
66
votes
6 answers
Regex and ISO8601 formatted DateTime
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…

TwystO
- 2,456
- 2
- 22
- 28
62
votes
6 answers
Turn postgres date representation into ISO 8601 string
I'm trying to format a Postgres date representation into a ISO 8601 string. I'm assuming that there is a Postgres function that can do it, but I found the documentation short on examples.
My query is
SELECT
now()::timestamp
which…

CallMeNorm
- 2,299
- 1
- 16
- 23
60
votes
4 answers
What mode for MySQL WEEK() complies with ISO 8601
What mode for MySQL's WEEK() function yields the ISO 8601 week of the year? Argument 2 of WEEK() sets the mode according to this chart:
+--------------------------------------------------------------------+
| Mode | First day of week | Range | Week…

steampowered
- 11,809
- 12
- 78
- 98
57
votes
5 answers
Converting timezone-aware datetime to local time in Python
How do you convert a timezone-aware datetime object to the equivalent non-timezone-aware datetime for the local timezone?
My particular application uses Django (although, this is in reality a generic Python question):
import…

kes
- 5,983
- 8
- 41
- 69