Well, the only solution I found is to create my custom time object by parsing the line
//ex: 2012-11-13T10:56:58-05:00 function CustomDate(timeString){ var completeDate = timeString.split("T")[0]; var timeAndOffset = timeString.split("T")[1]; //date this.year = completeDate.split("-")[0]; this.month = completeDate.split("-")[1]; this.day = completeDate.split("-")[2]; this.date = this.year + "/" + this.month + "/"+this.day; //negative time offset if (timeAndOffset.search("-") != -1){ var completeOffset = timeAndOffset.split("-")[1]; this.offset = parseInt(completeOffset.split(":")[0]) * -1; var originalTime = timeAndOffset.split("-")[0]; this.hours = parseInt(originalTime.split(":")[0]); this.minutes = parseInt(originalTime.split(":")[1]); this.seconds = parseInt(originalTime.split(":")[2]); this.time = this.hours + ":" + this.minutes + ":"+this.seconds; } ///positive time offset else if (timeAndOffset.search(/\+/) != -1){ var completeOffset = timeAndOffset.split("+")[1]; this.offset = parseInt(completeOffset.split(":")[0]); var originalTime = timeAndOffset.split("+")[0]; this.hours = parseInt( originalTime.split(":")[0]); this.minutes = parseInt(originalTime.split(":")[1]); this.seconds = parseInt(originalTime.split(":")[2]); this.time = this.hours + ":" + this.minutes + ":"+this.seconds; } //no time offset declared else{ this.hours = parseInt(timeAndOffset.split(":")[0]); this.minutes = parseInt(timeAndOffset.split(":")[1]); this.seconds = parseInt(timeAndOffset.split(":")[2]); this.offset = 0; this.time = this.hours + ":" + this.minutes + ":"+this.seconds; } }
For example, if I want to show what time is received on 2012-11-13T11: 34: 58-05: 00 at the specified time zone offset:
var aDate = new CustomDate("2012-11-13T11:34:58-05:00"); alert("date: " + aDate.date +" time: "+aDate.time+" offset: "+aDate.offset);
and i get
date: 2012/11/13 time: 11:34:58 offset: -5
The problem with this solution is that date and time conventions are manually defined in the code, so they will not be automatically adapted to the user language.
source share