You can use str_pad()
echo str_pad($value, 3, "0", STR_PAD_LEFT);
Or sprintf()
echo sprintf("%03d", $value);
Domanda
I'm calculating a countdown to a date. XXX Days Left. I'd like to show the hundreds place as zero if the total days left is less than 100.
This is where I'm at so far:
$now = time();
$your_date = strtotime(get_field('first_day'));
$datediff = abs($now - $your_date);
echo floor($datediff/(60*60*24));
Based on the target date, the output is 72. I'd like it to show 072.
Can someone help me with this?