Allah the almighty says:
And We have enjoined upon man, to his parents, good treatment. His mother carried him with hardship and gave birth to him with hardship, and his gestation and weaning [period] is thirty months. ... (46:15)
and He says also:
Mothers may breastfeed their children two complete years for whoever wishes to complete the nursing [period]. .. (2:233)
As for the second verse I'd say that it means that the maximum duration which counts as breastfeeding is two lunar years which are 24 months as explained in the Qur'an:
Indeed, the number of months with Allah is twelve [lunar] months in the register of Allah [from] the day He created the heavens and the earth; of these, four are sacred. That is the correct religion, so do not wrong yourselves during them. And fight against the disbelievers collectively as they fight against you collectively. And know that Allah is with the righteous [who fear Him]. (9:36)
which defines the length of a year.
I'd like to know how the 30 months duration from the first verse is explained or how it is defined?