php文件操作:PHP日期操作



//返回指定月份

function get_the_month_first_day_str($theyear, $themonth) {

date("Y-m-d", mktime(0, 0, 0, $themonth, 1, $theyear));

}



//返回指定月份最后

function get_the_month_last_day_str($theyear, $themonth) {

$theday = date("t", mktime(0, 0, 0, $themonth, 1, $theyear));

date("Y-m-d", mktime(0, 0, 0, $themonth, $theday, $theyear));

}



//返回指定日期所在周天(周日为第为第 2天以此类推)

function get_the_week_first_day_str($theyear, $themonth, $theday) {

$date = mktime(0, 0, 0, $themonth, $theday, $theyear);

$date = $date - (24 * 60 * 60 * date("w", $date));

date("Y-m-d", $date);

}



//返回指定日期所在周最后天(周日为第为第 2天以此类推)

function get_the_week_last_day_str($theyear, $themonth, $theday) {

$date = mktime(0, 0, 0, $themonth, $theday, $theyear);

$date = $date - (24 * 60 * 60 * date("w", $date)) + (24 * 60 * 60 * 6);

date("Y-m-d", $date);

}
Tags:  php当前日期 php日期函数 php日期 php文件操作

延伸阅读

最新评论

发表评论