joyo 发布的文章

<?php

$chars=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
$n=3;
print_r(array_intersect_key($chars,array_flip(array_rand($chars,$n))));

?>

当月总天数

echo date('t');

计算当前的时间距离下一个月还有多少天

function less_day(){
    $month_big = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
    //现在的月份
    $date_month_old = (int)date('m',time());
    //下个月的月份
    $date_month_new = $date_month_old + 1;
    //下个月1号的时间戳
    $date_time_new = strtotime('1 '.$month_big[$date_month_new-1].' '.date('Y',time()));
    //今天的时间戳
    $date_time_old = strtotime(date('d',time()).' '.$month_big[$date_month_old-1].' '.date('Y',time()));
    //距下月剩余时间
    $time_new = ($date_time_new - $date_time_old)/24/60/60-1;
    return $time_new;
}
header("Content-type: text/html; charset=utf-8");
echo '今天是:'.date('Y-m-d',time()).'<br/>';
echo '距离下个月还有:'.less_day().'天';

以上内容转载自https://bobjin.com/blog/view/4994c03c126159ba64788a0be6d59d6c.html 尊重原作者的劳动成果