I'd like to set the TTL based on the current date.
How is this possible in varnish?
Varnish honors the cache-headers sent by the backend - so setting appropriate expires-timestamps on your backend would be the best way to solve it.
If that is not an option, you would need to either develop a vmod, or implement this in in-line C within the VCL.
Developing a VMod, or writing in-line C in VCL is probably outside the scope of Serverfault, and should be brought up at Stack Overflow.