PHP display current and next month (unless date > 15) in which case show next month and next month +1

Posted on 2014-09-03
Last Modified: 2014-09-03

I'm looking to display the current and next month (unless date > 15) in which case show next month and next month +1

e.g. on  3rd Sept months shown to be September and October
...... on 16th Sept months shown to be October and November

points for full code please as I'm nearing a deadline :)
Question by:Neil Thompson
  • 2
LVL 11

Accepted Solution

Radek Baranowski earned 500 total points
ID: 40301191
if (date("d")<=15)
echo date("F",mktime(0,0,0,date("m"),1,2000))." ". date("F",mktime(0,0,0,date("m")+1,1,2000));
echo date("F",mktime(0,0,0,date("m")+1,1,2000))." ". date("F",mktime(0,0,0,date("m")+2,1,2000));

Open in new window


Author Comment

by:Neil Thompson
ID: 40301394
MAny thanks for this but when I also add the year "Y" it comes up with 2000, how can I get it to show the current year as well for each month please?

Author Closing Comment

by:Neil Thompson
ID: 40301413
just realised I just alter the 2000 to date("Y") to get current year :)
LVL 109

Expert Comment

by:Ray Paseur
ID: 40301418

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to use embargo Date/time in php 29 37
mysql between clause 2 22
Dynamic varibles 5 32
error log using ftp 7 39
This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

786 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