让我说说我需要问的条件:
我在WooCommerce上显示产品的开始销售和结束销售。循环代码如下:
<?php $thepostid = get_the_ID();
if ( $date = get_post_meta( $thepostid, '_sale_price_dates_from', true ) ) {
$sale_price_dates_from =
'<div class="fromsale">' .
'<span class="promodesc">' . esc_html__( 'Sale start:', 'mytheme' ). '</span>' .
'<span class="m">' . date_i18n( 'M', $date ) . '</span> ' .
'<span class="d">' . date_i18n( 'j', $date ) . '</span> ' .
'</div>'
;
} else {
$sale_price_dates_from =
'<div class="endsale">' .
'<span class="promodesc">' . esc_html__( 'No Schedule', 'mytheme' ). '</span> ' .
'</div>'
; }
echo $sale_price_dates_from ;
?>
<?php $thepostid = get_the_ID();
if ( $date = get_post_meta( $thepostid, '_sale_price_dates_to', true ) ) {
$sale_price_dates_to =
'<div class="endsale">' .
'<span class="promodesc">' . esc_html__( 'Sale end:', 'mytheme' ). '</span>' .
'<span class="m">' . date_i18n( 'M', $date ) . '</span> ' .
'<span class="d">' . date_i18n( 'j', $date ) . '</span> ' .
'</div>'
;
} else {
$sale_price_dates_to =
'<div class="endsale">' .
'<span class="promodesc">' . esc_html__( 'No Schedule', 'mytheme' ). '</span> ' .
'</div>'
; }
echo $sale_price_dates_to ;
?>
结果如下:
Sale start: May 13
Sale end: May 22
我很好奇,如何在开始和结束之间获得时间范围?在这种情况下,我想像这样显示倒计时(例如):
Sale will be end: 7days 20hours 33minutes 22seconds.
任何人都可以帮助我吗?
感谢任何帮助。