我正在计算一个日期的倒计时.XXX天左.如果总剩余天数小于100,我想将数百个地方显示为零.
这是我到目前为止的地方:
$now = time();
$your_date = strtotime(get_field('first_day'));
$datediff = abs($now - $your_date);
echo floor($datediff/(60*60*24));
Run Code Online (Sandbox Code Playgroud)
根据目标日期,输出为72.我希望它显示072.
有人可以帮我弄这个吗?
我已经对该主题进行了一些谷歌搜索,但由于浏览器对datalist元素的支持仍然很差,似乎没有人使用它或者之前没有真正问过这个问题.我有一个数据主义者:
<form>
<input placeholder="Enter a location or choose from the list" list="restaurants" id="hp-restaurants">
<datalist id="restaurants">
<option value="Sanford, ME" data-attr="<?php echo site_url(); ?>/locations/weathervane-restaurants/sanford/" />
<option value="Kitery, ME" data-attr="<?php echo site_url(); ?>/locations/weathervane-restaurants/kittery/" />
<option value="Belfast, ME" data-attr="<?php echo site_url(); ?>/locations/lobster-in-the-rough/belfast/" />
<option value="Waterville, ME" data-attr="<?php echo site_url(); ?>/locations/weathervane-restaurants/waterville/" />
<option value="Brewer, ME" data-attr="<?php echo site_url(); ?>/locations/weathervane-restaurants/brewer/" />
<option value="South Portland, ME" data-attr="<?php echo site_url(); ?>/locations/weathervane-restaurants/south-portland/" />
<option value="Bedford, NH" data-attr="<?php echo site_url(); ?>/locations/weathervane-restaurants/bedford-nh/" />
<option value="Dover, NH" data-attr="<?php echo site_url(); ?>/locations/weathervane-restaurants/dover-nh/" /> …Run Code Online (Sandbox Code Playgroud)