Status of PostgreSQL replication after pause and resume
Unless I misunderstood your question, SELECT extract(epoch from (now() - pg_last_xact_replay_timestamp())) AS time_lag; should give you what you are looking for - the lag in seconds, not seconds portion of the lag as your original query returns.  You can achieve the same with a number of extract (seconds ...) + extract(minutes ...)*60 + extract (hours ...) *60*24 +...