Solved

Display date, based on date... something

Posted on 2013-01-08
4
225 Views
Last Modified: 2013-01-08
Hi,

I pay my affiliates twice per month (1st and 15th) and would like a function to output the next payment date.

How should I go about that?
0
Comment
Question by:kgp43
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Slimshaneey earned 500 total points
ID: 38756235
You could do something like this:

//===
//If day part of month is 15 or greater, next payment will be first of next month
//===
$now = getdate();

if($now['day'] >= 15){
//Your next payment is on the 1st

$nextmonth = ($now['mon'] + 1) % 13 + 1;
$year = $now['year'];
if($nextmonth == 1)
    $year++;
$thefirst = gmmktime(0, 0, 0, $nextmonth, $year);

//Here, use date function to format the timestamp in thefirst var

}else{
//Your next payment is on the 15th

$thefifteenth = gmmktime(0, 0, 15, $now['mon'], $now['year']);
}

Open in new window


I havent tested this but it should get you there abouts for your needs
0
 

Author Comment

by:kgp43
ID: 38756366
Will this work? (got an idea after looking at your code)

function NextPaymentDate() {
	
	# Next payment is the 1st
	if(date('d') >= 15) {

		$month = date('Month', strtotime('+1 month'));
		$year = date('Y',strtotime('+1 month'));

		return $month." 1st, ".$year;

	}else{
		
		# Next payment is on the 15th
		return date('F')." 15th, ".date('Y');
	}
}

Open in new window

0
 
LVL 11

Expert Comment

by:Slimshaneey
ID: 38756378
That should work just fine! I just went with timestamps as wasnt sure how you wanted to display the dates.
0
 

Author Comment

by:kgp43
ID: 38756399
Perfect, thanks for your help :)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now