Avatar of kgp43
kgp43
Flag for Denmark asked on

Display date, based on date... something

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?
PHP

Avatar of undefined
Last Comment
kgp43

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Slimshaneey

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
kgp43

ASKER
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

Slimshaneey

That should work just fine! I just went with timestamps as wasnt sure how you wanted to display the dates.
kgp43

ASKER
Perfect, thanks for your help :)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy