Answer the question
In order to leave comments, you need to log in
Parsing date from ISO 8601
There is a string in ISO format 2005-08-09T18:31:42+03:30
How can I find out from here that the time zone is +03:30?
Is there any library?
Answer the question
In order to leave comments, you need to log in
You can use date.js or just a regular expression
var rx = /[+-]\d{2}\:?(?:\d{2})?$/;
"2005-08-09T18:31:42+03:30".match(rx); // ["+03:30"]
"2005-08-09T18:31:42+0330".match(rx); // ["+0330"]
"2005-08-09T18:31:42+03".match(rx); // ["+03"]
// Или более правльный формат таймзоны
var rx = /[+-]\d{2}\:?\d{2}$/; // не включает короткую запись таймзоны 2005-08-09T18:31:42+03 - такие даты так же не парсят браузеры
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question