[Solved] Edit date/time string via Javascript/jQuery


You can follow this code:

HTML

<div class="date-string">2016-01-14T10:30:37+02:00</div>
<div class="date-string">2013-02-16T10:30:37+02:00</div>
<div class="date-string">2017-03-15T10:30:37+02:00</div>

JavaScript

var	d, newDateFormat;

function getZero(number){
	if(number < 10) return '0' + number;
	return number;
}

$('.date-string').each(function(){
	d = new Date($(this).html());

	newDateFormat = getZero(d.getDate()) + "https://stackoverflow.com/" + getZero(d.getMonth() + 1) + "https://stackoverflow.com/" + d.getFullYear();

	$(this).html(newDateFormat);
});

And here is the output:

enter image description here

2

solved Edit date/time string via Javascript/jQuery