The first half is a line by the Tang poet
王贞白; the whole saying appears in the Ming-era 《
增广贤文》 ('Expanded Words of Wisdom'), a collection used for moral education in late imperial schools. The expanded second half adds the philosophical kicker: gold is replaceable, time is not.