Forum Moderators: coopster

Message Too Old, No Replies

php date settings

php date time function

         

booney1983

3:56 pm on Sep 30, 2008 (gmt 0)

10+ Year Member



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
-----------------------------------------------------------------

$sikecem = date($item_details['purchase_date'] + (03 * 24 * 60 * 60));
$elif = time();
$yarak = $elif > $sikecem;
if ($yarak)
{
$sold_auctions_content ;
}

daveginorge

10:17 am on Oct 1, 2008 (gmt 0)

10+ Year Member



I would try something like

// Get the Weekday number
$Day = date("w", $item_details['purchase_date']);

// Test the day
switch($Day) {
// Sunday (+ 3) = Wednesday
case "0":
// Moday (+ 3) = Thursday
case "1":
// Tuesday (+ 3) = Friday
case "2":
$sikecem = date($item_details['purchase_date'] + (03 * 24 * 60 * 60));

// Wednesday (+ 5) = Monday (Thurs, Fri, Mon)
case "3":
// Thursday ( + 5) = Tuesday (Fri, Sat, Sun, Mon, Tue)
case "4":
// Friday (+ 5) = Wednesday (Sat, Sun, Mon, Tue, Wed)
case "5":
$sikecem = date($item_details['purchase_date'] + (05 * 24 * 60 * 60));

// Saturday (+ 4) = Wednesday (Sun, Mon, Tue, Wed)
case "6":
$sikecem = date($item_details['purchase_date'] + (04 * 24 * 60 * 60));
}


Maybe the syntax needs some attention but the idea is there.

daveginorge

4:09 pm on Oct 1, 2008 (gmt 0)

10+ Year Member



Amendment to my POST

// Get the Weekday number
$Day = date("w", $item_details['purchase_date']);

// Test the day
switch($Day) {
// Sunday (+ 3) = Wednesday
case "0":
// Monday (+ 3) = Thursday
case "1":
// Tuesday (+ 3) = Friday
case "2":
$sikecem = date($item_details['purchase_date'] + 03 * 24 * 60 * 60);
break;

// Wednesday (+ 5) = Monday (Thurs, Fri, Sat, Sun, Mon)
case "3":
// Thursday ( + 5) = Tuesday (Fri, Sat, Sun, Mon, Tue)
case "4":
// Friday (+ 5) = Wednesday (Sat, Sun, Mon, Tue, Wed)
case "5":
$sikecem = date($item_details['purchase_date'] + 05 * 24 * 60 * 60);
break;

// Saturday (+ 4) = Wednesday (Sun, Mon, Tue, Wed)
case "6":
$sikecem = date($item_details['purchase_date'] + 04 * 24 * 60 * 60);
break;
}