1
我的按鈕上寫着Accept
,從創建時開始應該僅對72 HOURS
有效,而在過去的72時,它應該自動禁用,並在<span>
中發出消息。如何使用PHP和jQuery動態設置按鈕的到期時間?
PHP:
這是我的時間收集變量
$original_datetime = new DateTime($_item['updated_at']);
$expire_time = $original_datetime->modify("+72 hours");
HTML:與其10000
即10秒
<input type="button" id="acceptBtn" value="<?php echo $this->__('Accept') ?>"
data-created-at="<?php echo $original_datetime->format("d-M-Y H:i:s"); ?>"
data-expiring-at="<?php echo $expire_time->format("d-M-Y H:i:s"); ?>" ><br>
<span id="expired_message"></span>
jQuery的
jQuery(document).ready(function ($) {
disableAcceptButton();
}
function disableAcceptButton() {
setTimeout(function() {
jQuery("#acceptBtn").prop("disabled", true).hide();
jQuery("#expired_message").text('Sorry, time expired, if you wish to buy/sell this Product again, Contact Admin via Email');
}, 10000);
}
,這應該從創建起3天后過期。
幫助。
的jQuery不會幫助,因爲用戶無法打開一個頁面3天...你必須節省分貝 – Babar
之日起計算「結束」日期並將其存儲在一個數據庫,那麼當EV呃調用頁面/按鈕,檢查按鈕是否仍然有效。 – Epodax
你能告訴我$ expire_time var格式嗎? –