Greetings! I am facing an issue where every time a year is added, it gets inserted between the day and month in the date of entry for a user at our company.
var yearOnCompany = moment(user.fecha_ingreso_empresa, "YYYYMMDD").fromNow();
var dateStart = moment(user.fecha_ingreso_empresa).format("DD-MM-YYYY");
console.log(dateStart);
//03-12-2009
var f = parseInt(yearOnCompany);
var yearsOfWork = [];
for(var i = 1; i <= f; i++)
{
dateStart = moment(dateStart, "DD-MM-YYYY").add(1, 'years').calendar();
yearsOfWork.push(dateStart);
}
console.log(yearsOfWork);
Here is the result:
0:"12/03/2010"
1:"03/12/2011"
2:"12/03/2012"
3:"03/12/2013"
4:"12/03/2014"
5:"03/12/2015"
6:"12/03/2016"
7:"03/12/2017"