tjyoung
asked on
Trying to determine how many 'selling' days left in a month
Hi,
Our business isn't open on Sundays. In my app I need to show how many selling days are left in the month (days we are open). Currently you can show how many days left in a month using something like this:
<?php echo date('t') - date('j');?>
But how could I take into account Sundays?
Our business isn't open on Sundays. In my app I need to show how many selling days are left in the month (days we are open). Currently you can show how many days left in a month using something like this:
<?php echo date('t') - date('j');?>
But how could I take into account Sundays?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not really. Don't have access to 5.2 any more!
The diff() method is also >=5.3.
You really ought to upgrade your system though - for security reasons if nothing else. If this is a hosted platform, then chase them up (or change providers)
The diff() method is also >=5.3.
You really ought to upgrade your system though - for security reasons if nothing else. If this is a hosted platform, then chase them up (or change providers)
Hmmm. Thought a little more and maybe try this. We don't actually need the date of the end of the month, just the day number, which you can get with format('t'):
$start = new DateTime();
$days = $start->format('t') - $start->format('d');
$sundays = intval($days / 7) + ($start->format('N') + $days % 7 >= 7);
$sellingDays = $days - $sundays;
printf("The are %d selling days left this month", $sellingDays);
ASKER
Great trying it now...
ASKER
Awesome, that did the trick! I appreciate you taking another look Chris.
Thanks again,
Todd
Thanks again,
Todd
No worries ;)
ASKER
'last day of this month' for example doesn't work unless its 5.3 and above and I can't upgrade the machine unfortunately....