Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Display date, based on date... something

Posted on 2013-01-08
4
Medium Priority
?
239 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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 …
Suggested Courses

886 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