How to restrict internet time-based via iptables?

The iptables command works, you don’t need to patch anything. Just keep in mind that it will only “block” IPv4. If you have both IPv4 and IPv6, you would need to block both.

Also keep in mind that it is just TCP, depending on how you test your connection, it might looks like it is working. Ping will still work, also DNS and the UDP based QUIC protocol.