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 https://www.greaterwrong.com/posts/RApxEu3A4GnvGoEe2/self-sacrifice-is-a-scarce-resource:
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.