well isn't there some way to make a transaction that the public key is only revealed once it is spent into a block? if so then it seems like the public key itself could be the secret key to unlocking the data.
It is always true in any hash-based address, so P2PKH, P2SH, P2WPKH, P2WSH, and non-standard scripts with any hashing opcodes, applied to public keys. But if you use some public key as your secret, then you have to share your transaction somehow. If you will do that alone, then no timelock is needed, because you can encrypt things normally, and reveal the password at the right time, then using timelock will be pointless if you can fully control the whole process, and if you are the central point that will release the key. And if you pass that transaction to any third party before releasing, then that party will know the password, and can unlock your data, even if your transaction will be timelocked.
So, hiding your public key is possible, but if you want to make some data locked by time, then you cannot control it alone, or pass your unlocking key unencrypted to anyone, because then your timelock will not be enforced.
Instead, you can look at the simplest timelock: executing hash function multiple times. For example, you can start by using the Genesis Block hash, and hash it multiple times.
SHA-256(0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c)=af42031e805ff493a07341e2f74ff58149d22ab9ba19f61343e2c86c71c5d66d
SHA-256(af42031e805ff493a07341e2f74ff58149d22ab9ba19f61343e2c86c71c5d66d)=6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000
SHA-256(6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000)=0df32bc40af15b76d566c9b50e0eb02fa3ef0913db04b1beb01ad55a3b590d30
SHA-256(0df32bc40af15b76d566c9b50e0eb02fa3ef0913db04b1beb01ad55a3b590d30)=b60eed28264507e1289dae289b58e284541e1b5c9c8611c319d0c5719a0c2cf8
And then, you can repeat that process, for example 2^32 times. Then, you will get some key, and you can encrypt your data with any symmetric encryption, like AES. Then, you can share some simple program for calculating those hashes, and it will guarantee that your data will be unlocked after calculating 2^32 hashes, what can be done on CPUs in for example 10 minutes. The drawback is that if you want to lock things for a month, then you need to spend a month to compute that. There are better ways with better complexity, also described by Gwern in the article linked above, but that simple concept should be enough to understand, what those timelocks are about.