Wilson Campusano
Wilson Campusano

Reputation: 616

NaN when parsing value returned by parseInt() and toLocaleString Internet Explorer

alert(parseInt(new Date().toLocaleString('es', {month:'numeric'})));

This code always return 'NaN' on IE

why is this?

how can i solved only using vanilla javascript.

Upvotes: 1

Views: 1047

Answers (1)

brso05
brso05

Reputation: 13232

var date = new Date();
var month = date.getMonth() + 1; //Months are zero based

This should work for you to get the month.

Upvotes: 3

Related Questions