91
rated 0 times
[
98]
[
7]
/ answers: 1 / hits: 46642
/ 9 Years ago, thu, april 9, 2015, 12:00:00
I am getting from api xml data, where one of the xml elements is date time, which nodeValue is always in this format - string: YYYY-MM-DD. (I can not request from api, to return me date time in diffrent format)
My problem is to split and convert this format into this string: DD.MM.YYYY
Basicly I did this:
var myString = 2015-04-10; //xml nodeValue from time element
var array = new Array();
//split string and store it into array
array = myString.split('-');
//from array concatenate into new date string format: DD.MM.YYYY
var newDate = (array[2] + . + array[1] + . + array[0]);
console.log(newDate);
Here is jsfiddle: http://jsfiddle.net/wyxvbywf/
Now, this code works, but my question is: Is there a way to get same result in fewer steps?
More From » string