How is the new month determined:
The months in the Islamic calendar start and end with the sighting of the new moon. The following ahadith are regarding the instructions of the Prophet ﷺ regarding Ramadan, Shawal and Dhu’l-Hijjah, and the same extends to other months:
لا تصوموا حتى تروا الهلال، ولا تفطروا حتى تروه
Do not fast unless you see the crescent (of Ramadan), and do not give up fasting till you see the crescent (of Shawwal)
عهد إلينا رسول الله صلى الله عليه وسلم أن ننسك للرؤية فإن لم نره وشهد شاهدا عدل نسكنا بشهادتهما
The Messenger of Allah (ﷺ) took a pledge from us that we should perform the rites of hajj after sighting the moon. If we do not sight it and two reliable persons bear witness, we should perform the rites of hajj on the basis of their witness.
— Abu Dawud
صوموا لرؤيته وأفطروا لرؤيته وانسكوا لها فإن غم عليكم فأكملوا ثلاثين فإن شهد شاهدان فصوموا وأفطروا
Fast when you see it and stop fasting when you see it, and perform the rites on that basis. If it is obscured, then complete thirty days, and if two witnesses testify then fast and stop fasting.
اختلف الناس في آخر يوم من رمضان فقدم أعرابيان فشهدا عند رسول الله صلى الله عليه وسلم بالله لأهلا الهلال أمس عشية فأمر رسول الله صلى الله عليه وسلم الناس أن يفطروا
People differed among themselves on the last day of Ramadan (about the appearance of the moon of Shawwal). Then two bedouins came and witnessed before the Prophet (ﷺ) swearing by Allah that they had sighted moon the previous evening. So the Messenger of Allah (ﷺ) commanded the people to break the fast.
— Abu Dawud
On the evening when the 29th day of a month has ended, Muslims look at the sky to search for the new crescent. If anyone manages to see it they report their testimony to the caliph (or his appointed deputy).
If a number of valid testimonies are received then the caliph will declare the start of the new month. If no valid testimonies are received then it is assumed that moon was not visible and hence the month is declared to be of 30 days.
In modern times countries have government sanctioned authorities / committees / courts who look for the moon themselves and also receive and validate testimonies from witnesses who claim to have sighted it. When they get enough reliable testimonies they announce the start of the month. This announcement gets on the internet just like any other news does.
Why your calculation is wrong?
17th July 2023 was 29th Dhu’l-Hijjah in Saudia Arabia. However the moon was not sighted that evening. The next day (18th July) the moon was sighted - although even if it hadn't been sighted the month would have ended as it can not be longer than 30 days. Hence the day after (19th July) was declared to be the 1st of Muharram. (ref khaleejtimes , gulfnews).
Your calculation is wrong because it assumes that the month starts with the astronomical new moon, or it assumes that the moon will always be visible right after the conjunction. This does not take into account all the factors governing visibility, and hence leads to a wrong answer.
As per my understanding, doing a slightly more comprehensive calculation leads to the correct outcome that agrees with what happened in reality:
The conjunction (birth of the new moon) happened when the time was 17th July 9:32 pm in Saudia Arabia. The Astro::MoonPhase library agrees with this as can be verified by using the phasehunt() function.
However the moon had already set in Saudia Arabia before that time - and gone underneath the horizon. So it was not going to be visible. (ref: timeanddate.com)
Hence it would only be seen on 18th July, making 19th July as the first 'day' of Muharram.
Note however that the visibility of the moon depends on more than just being born and being above the horizon ... it also depends on its brightness and size, the weather conditions, the intensity of twilight, the presence of an observer and the strength of his eyesight etc. Calculation criterion can not account for every factor and hence can only give you a probability of sighting the moon.