-3
我需要一些PHP的幫助PHP倒計時 - 如何使用否則如果幾個小時時,有不到1天離開
這裏是我的代碼
<?php
// Define your target date here
$targetYear = get_theme_option('episode_countdown_year');
$targetMonth = get_theme_option('episode_countdown_month');
$targetDay = get_theme_option('episode_countdown_day');
$targetHour = 21;
$targetMinute= 00;
$targetSecond= 00;
date_default_timezone_set ("America/New_York");
// Sets the default time zone, in this case GMT -08
$dateFormat = ("Y-m-d H:i:s");
// Check the PHP Documentation for date uses.
$targetDate = mktime (
$targetHour,
$targetMinute,
$targetSecond,
$targetMonth,
$targetDay,
$targetYear
);
// Sets up our timer
$actualDate = time();
// Gets the actual date
$secondsDiff = $targetDate - $actualDate;
// Finds the difference between the target date and the actual date
// These do some simple arithmatic to get days, hours, and minutes out of seconds.
$remainingDay = floor ($secondsDiff/60/60/24);
$remainingHour = floor (($secondsDiff - ($remainingDay
*60 * 60 * 24))/60/60);
$remainingMinutes = floor (($secondsDiff - ($remainingDay
*60 * 60 * 24) - ($remainingHour * 60 * 60))/60);
$remainingSeconds = floor (($secondsDiff - ($remainingDay
*60 * 60 * 24) - ($remainingHour * 60 * 60)) -
($remainingMinutes * 60));
$targetDateDisplay = date($dateFormat,$targetDate);
$actualDateDisplay = date($dateFormat,$actualDate);
// Sets up displays of actual and target
?>
<?php if($targetDate > $actualDate) {?>
description: '<?php echo $remainingDay; ?> Day(s)/<?php echo $remainingHour; ?> Hour(s)/<?php echo $remainingMinutes; ?> Minute(s) Left..',
picture: '<?php echo $my_url ?>/cache/image-<?php echo $remainingDay; ?>-d.png'
<?php } else { ?>
description: 'Now Showing!',
picture: '<?php echo $my_url ?>/image-now.php'
<?php } ?>
我的問題是
如何我可以添加其他代碼,如果還有不到1天
所以我可以隱藏剩餘日期,所以只有小時和分鐘顯示
我試過,但沒有工作
<?php } else if($remainingDay < $actualDate) {?>
不起作用,試了一下 – LCallaghan84
使用的邏輯,而不是確切的代碼。這是怎麼回事? –
現在的作品 - 感謝您的幫助 – LCallaghan84