利用PHP怎么計算一年有幾周?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
在路橋等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站制作、成都網(wǎng)站設(shè)計 網(wǎng)站設(shè)計制作定制網(wǎng)站制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),成都全網(wǎng)營銷推廣,外貿(mào)網(wǎng)站制作,路橋網(wǎng)站建設(shè)費(fèi)用合理。下面通過兩種方式實現(xiàn)PHP獲取一年有幾周以及每周開始日期和結(jié)束日期
代碼一:
'; if ($week > $weeks || $week <= 0) { $week = 1; } if ($week < 10) { $week = '0' . $week; } $timestamp['start'] = strtotime($year . 'W' . $week); $timestamp['end'] = strtotime('+1 week -1 day', $timestamp['start']); echo $year . '年第' . $week . '周開始時間戳:' . $timestamp['start'] . '
'; echo $year . '年第' . $week . '周結(jié)束時間戳:' . $timestamp['end'] . '
'; echo $year . '年第' . $week . '周開始日期:' . date("Y-m-d", $timestamp['start']) . '
'; echo $year . '年第' . $week . '周結(jié)束日期:' . date("Y-m-d", $timestamp['end']); ?>
代碼二:
setISODate($year, 53); return ($date->format("W") === "53" ? 53 : 52); } function weekday($custom_date) { $week_start = date('d-m-Y', strtotime('this week monday', $custom_date)); $week_end = date('d-m-Y', strtotime('this week sunday', $custom_date)); $week_array[0] = $week_start; $week_array[1] = $week_end; return $week_array; } echo '
Weeks in 2013
' . getIsoWeeksInYear(2013); $weekday = weekday(strtotime(date('d-m-Y', strtotime('5-8-2013')))); echo '
10-8-2013'; echo '
Start: ' . $weekday[0]; echo '
End: ' . $weekday[1]; ?>
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,的支持。