As Vitamin D is fat soluble, it has to be taken with a fatty acid that can serve as a transport.
It is likely easiest to take Vitamin D with a meal, but you can also pair it with a fat like Fish Oil or a teaspoon of coconut oil.
There is anecdotal reports that it might disrupt sleep if taken later in the evening, so it might be better taken earlier in the day as a precaution.