Solved

Display date, based on date... something

Posted on 2013-01-08
4
227 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Animated .jpg? 13 63
A form to still have contents even if some are wrong 10 47
updating the date data 12 25
Convert html page to a php post email form automatically? 10 34
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

863 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

21 Experts available now in Live!

Get 1:1 Help Now