How does Google know when a URL was last updated?

Google can show when a URL was last updated. For example, it shows Jun 27, 2020 for
enter image description here

How does Google calculate that date? Is there a way I can calculate that myself, or is scraping Google the best solution?

PS: The last-modified HTTP header is garbage and often fake.