gpt4 book ai didi

javascript - PHP 和 jquery 倒计时

转载 作者:行者123 更新时间:2023-12-03 08:35:12 24 4
gpt4 key购买 nike

我刚刚得到了一个集成 PHP 日期函数和 jQuery 的教程。

我想自定义脚本,以便在特定时间到达其重定向到另一个页面。

我尝试自己做,但它无法正常工作。我已在此处添加了教程链接。

Tutorial LInk

从服务器获取日期的 PHP 代码

<?php
date_default_timezone_set('GMT');
$currentTime = date('H:i:s');
$currentDay = date('w');
$delTimeStart = '00:00:00';
$delTimeEnd = '14:30:00';
if ($currentTime >= $delTimeStart && $currentTime < $delTimeEnd && $currentDay > 0 && $currentDay < 6){
$css = 'display: block;';
} else {
$css = 'display: none;';
}
?>

JS脚本

<script type="text/javascript">
$('#countdowntimer').countdown('<?php $date = strtotime("+1 day"); echo date('Y/m/d', $date); ?> 14:30:00').on('update.countdown', function(event) {
var $this = $(this).html(event.strftime(''
+ '%H Hours '
+ '%M Minutes '
+ '%S Seconds'
));
});
</script>

最佳答案

试试这个 - 收集自 the source :

FIDDLE

$('#countdowntimer').countdown('<?php $date = strtotime("+1 day"); echo date('Y/m/d', $date); ?> 14:30:00')
.on('update.countdown', function(event) {
$(this).html(event.strftime(''
+ '%H Hours '
+ '%M Minutes '
+ '%S Seconds'
));
})
.on('finish.countdown', function(event) {
location.replace("someurl");
});

关于javascript - PHP 和 jquery 倒计时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33235872/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com