New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with "Date.prototype.getMonth()": (short summary here please) #5298
Comments
Fortunately, we will probably have proposal-temporal in the ECMAScript specification next year and then we can polyfill or shim it as required. In particular, After that, I expect best practise will be to avoid |
Well, according to that new standard or development, it is still necessary:
|
Perhaps
new Intl.DateTimeFormat("en-US", {year: "numeric"}).format(new Date);
new Intl.DateTimeFormat("en-US", {year: "2-digit"}).format(new Date);
new Intl.DateTimeFormat("en-US", {month: "2-digit"}).format(new Date);
I'm unclear what a matrix of 12 positions refers to.
new Intl.DateTimeFormat("en-US", {day: "2-digit"}).format(new Date); There is a polyfill for |
This issue doesn’t appear to be about how |
MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth
What information was incorrect, unhelpful, or incomplete?
I suppose that for generations this has been working this way ... but I think that at some point it should be corrected.
when using and or creating the Date object
var now = new Date();
works correctly, but trying to extract information is where a multitude of concepts occurs:
first concept:
now.getFullYear()
get the current 4-digit year, work nice.
second concept:
now.getDate()
gets the day of the given date.
third concept:
now.getMonth()
**returns the position of the month starting from 0, what has happened with this concept, this is horrible ... if we follow the pattern of names I should get the number of the current month based / starting from 1 for January to 12 December ... This concept does not apply the same with days or years. **
I think that what is tried with this method was to obtain the position for which there should be a named method:
now.getMonthPosition()
over time a numerical patch had to be inserted to calculate the month correctly:
let mm = next.getMonth()+1;
The text was updated successfully, but these errors were encountered: