我从http://www.phpcodeworks.com/pec/installation下载事件日历。我使用PHP 5.3.X因此浏览器说 F:\ xampp \ htdocs \ msj \ functions.php 所以我更换:
$days = date("t", mktime(0,0,0,$month,1,$year));
使用:
$days = date("t",` time(0,0,0,$month,1,$year));
但这样做的每个日期都会在24小时后回复。
使用$days = date("t", mktime(0,0,0,$month,1,$year));
时的图片:
使用$days = date("t", time(0,0,0,$month,1,$year));
时的图片:
答案 0 :(得分:10)
mktime()
函数返回从Unix Epoch(1970年1月1日00:00:00 GMT)到作为参数提供的日期和时间的秒数。
time()
函数返回从Unix Epoch(1970年1月1日00:00:00 GMT)到函数运行时的秒数。没有参数可以传递。
因此,在浏览特定日期时,您需要使用mktime()
代替time()
,time()
每次运行时都会不断返回不同的数字。因此,每次查看时,您的日历都会发生变化(即使您正在尝试查看特定日期)。
<强> Hightlight:强>
mktime()
- 表示指定日期的秒数(请参阅所需参数的文档)。
time()
- 现在表示的秒数(此函数没有参数)。
mktime()
看起来是适合这种情况的函数。