Differentiable Optimization Based Time-Varying Control Barrier Functions for Dynamic Obstacle Avoidance