0
我已經設置了這個旋轉日曆昨天,我想我可能會遇到問題,並確信今天發生了我期望的問題。日子改變時日期發生了變化。它沒有像昨天那樣跳過週末,而是週六而不是週一。這只是假設顯示星期一至星期五和超過+3,並回到星期一至星期五。示例代碼:php日期函數和計算每週的幾天以確保週末跳過
echo "Today";
echo date('m/d');
echo "<br>";
echo substr(date('l/m/d', strtotime('+1 day')), 0, 2). date('m/d', strtotime('+1 day'));
echo "<br>";
echo substr(date('l/m/d', strtotime('+2 day')), 0, 1). date('m/d', strtotime('+2 day'));
echo "<br>";
echo substr(date('l/m/d', strtotime('+5 day')), 0, 1). date('m/d', strtotime('+5 day'));
echo "<br>";
echo substr(date('l/m/d', strtotime('+6 day')), 0, 1). date('m/d', strtotime('+6 day'));
echo "<br>";
echo substr(date('l/m/d', strtotime('+7 day')), 0, 1). date('m/d', strtotime('+7 day'));
echo "<br>";
echo substr(date('l/m/d', strtotime('+8 day')), 0, 2). date('m/d', strtotime('+8 day'));
echo "<br>";
echo substr(date('l/m/d', strtotime('+9 day')), 0, 1). date('m/d', strtotime('+9 day'));
echo "<br>";
echo substr(date('l/m/d', strtotime('+12 day')), 0, 1). date('m/d', strtotime('+12 day'));
echo "<br>";
echo substr(date('l/m/d', strtotime('+13 day')), 0, 1). date('m/d', strtotime('+13 day'));
顯然模式沒有完成工作,我如何確保週末總是跳過?
此外,我concating這成sql查詢像這樣:(實際代碼)
sum(case when cast(a.follow_up as date)=cast(GETDATE() as date) then 1 else 0 end) 'Today<br> " . date('m/d') . "',
sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='1' then 1 else 0 end) '" . substr(date('l/m/d', strtotime('+1 day')), 0, 2).'<br>' . date('m/d', strtotime('+1 day')) . "',
sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='2' then 1 else 0 end) '" . substr(date('l/m/d', strtotime('+2 day')), 0, 1).'<br>' . date('m/d', strtotime('+2 day')) . "',
sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='3' then 1 else 0 end) '" . substr(date('l/m/d', strtotime('+5 day')), 0, 1).'<br>' . date('m/d', strtotime('+5 day')) . "',
sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='4' then 1 else 0 end) '" . substr(date('l/m/d', strtotime('+6 day')), 0, 1).'<br>' . date('m/d', strtotime('+6 day')) . "',
sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='5' then 1 else 0 end) '" . substr(date('l/m/d', strtotime('+7 day')), 0, 1).'<br>' . date('m/d', strtotime('+7 day')) . "',
sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='6' then 1 else 0 end) '" . substr(date('l/m/d', strtotime('+8 day')), 0, 2).'<br>' . date('m/d', strtotime('+8 day')) . "',
sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='7' then 1 else 0 end) '" . substr(date('l/m/d', strtotime('+9 day')), 0, 1).'<br>' . date('m/d', strtotime('+9 day')) . "',
sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='8' then 1 else 0 end) '" . substr(date('l/m/d', strtotime('+12 day')), 0, 1).'<br>' . date('m/d', strtotime('+12 day')) . "',
sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='9' then 1 else 0 end) '" . substr(date('l/m/d', strtotime('+13 day')), 0, 1).'<br>' . date('m/d', strtotime('+13 day')) . "',
'的strtotime( 「 - 」(日期( 「N」) - 1)「天 「);'會帶你回到週一,然後使用'的strtotime(」 +1天「,$ lastmonday);' – Waygood 2013-05-01 17:01:45
你可以用'date(」D m/d「);'而不是砍掉」l/m/d「 – Waygood 2013-05-01 17:06:37
這可能是我正在尋找的方式,我會搏一搏。謝謝。 – 2013-05-01 17:08:47