时间戳转换(PHP)

/**

 * 今天的时间

 */

function nowdaytime(){

    return strtotime(date('Y-m-d',time()));

}



/**

 * 本周第一天

 */

function weektime(){

    return strtotime(date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)));

}



/**

 * 本周第一天

 */

function weekfirsttime(){

    $date=new \DateTime();

    $date->modify('this week');

    $first_day_of_week=$date->format('Y-m-d');

    return strtotime($first_day_of_week);

}



/**

 * 本周最后一天

 */

function weeklasttime(){

    $date=new \DateTime();

    $date->modify('this week');

    $date->modify('this week +6 days');

    $last_day_of_week=$date->format('Y-m-d');

    return strtotime($last_day_of_week);

}

 

猜你喜欢

转载自blog.csdn.net/weixin_39984546/article/details/84934943