php date settings

Discussion in 'PHP' started by booney1983, Oct 1, 2008.

  1. #1
    Dear friends,
    İ've got an shopping site and have some problems with these codes, Here's the a part of my codes mean;
    $item_details['purchase_date'] ==>> User's good order date.

    with this codes,i give the user 3 days to pay the cost. i count 3 days after the order day and show him $sold_auctions_content after this 3 days. i do nothing in this 3 days.
    here's the my problem. i would like to count only 3 days in Munday,Tuesday,Wednesday,Thursday and Friday. Not include Saturday and Sunday, also 1st January (and other official holidays). Because,the banks doesnt work these days in my country.

    two examples:
    1-)
    if user order a computer in the Monday, he has 3 days to pay (Tuesday,Wednesday,Thursday).. its ok.

    2-)
    if user order a computer in the Friday, he has 3 days to pay (these days must be Monday,Tuesday,Wednesday. Not saturday,sunday and monday)

    How could i do that with these php codes?
    P.S : if someone tell me another way , i can use it with pleasure..

    With Best Regards
    -----------------------------------------------------------------
    Here's my codes

    $ahmet = date($item_details['purchase_date'] + (03 * 24 * 60 * 60));
    $elif = time();
    $necati = $elif > $ahmet;
    if ($necati)
    {
    $sold_auctions_content ;
    }
     
    booney1983, Oct 1, 2008 IP
  2. spc

    spc Well-Known Member

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    125
    #2
    Get the weekday from $item_details['purchase_date']

    use $wkday = date('l'); //will result weekday as text. ex: Sunday
    or $wkday = date('N'); // as number: 1 (for Monday) through 7 (for Sunday)


    if weekday is sunday through tuesday, use 3
    ahmet = date($item_details['purchase_date'] + (03 * 24 * 60 * 60));

    if weekday is wednesday or thursday or saturday, use 4
    ahmet = date($item_details['purchase_date'] + (04 * 24 * 60 * 60));

    if weekday is friday, use 5
    ahmet = date($item_details['purchase_date'] + (05 * 24 * 60 * 60));


    Hope it helps!
     
    spc, Oct 1, 2008 IP