I have this code:
var utc = moment.tz(1521221491000, "UTC");
var local = utc.clone().tz(moment.tz.guess());
console.log(moment([2018, 03, 15]).fromNow());
console.log('moment() piece by piece: ' + moment().get('year') + ' ' + moment().get('month') + ' ' + moment().get('date') + '. Data inside of momment: ' + moment().format());
console.log(local.format("YYYY-MM-DD HH:MM:SS"));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.21.0/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.14/moment-timezone-with-data.js"></script>
In the line 3
console.log(moment([2018, 03, 15]).fromNow());
Suppose to say '1 day ago', at the moment to write this question is 16 of March 2018... And for some reason the response is
in a month...
Any idea why this error, the error is in the month var.