By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,656 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

php date settings

P: 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:
if user order a computer in the Monday, he has 3 days to pay (Tuesday,Wednesday,Thursday).. its ok.

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

[PHP]$ahmet = date($item_details['purchase_date'] + (03 * 24 * 60 * 60));
$elif = time();
$necati = $elif > $ahmet;
if ($necati)
$sold_auctions_content ;
Oct 1 '08 #1
Share this Question
Share on Google+
1 Reply

P: 44
There's no single function in PHP that can do this. But using the date function you could get this working. See:

Using the 'N' format you can get the day of the week in the form 1..7. So a simple if excluding 6 and 7 would discard weekends. As far as holidays go you'll probably have to check each one manually. I suggest storing all of your recognized holidays in an array and loop through and compare for each day.

So write a loop that will go one day at a time from the order date, use date with 'N' to see if it is a weekend, if so skip it. Use your array to see if it is a holiday, if so skip. If both pass increment a counter. Go the the next day and repeat until your counter is 3, then you have the date 3 business days later.

Hope that makes sense.
Oct 10 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.