Jump to content

[SOLVED] Trying To Use Time Function To Return Next Month


Recommended Posts

I am using a calendar script that uses the current time to show the current month's calendar.  What I am trying to do is get the next month's calendar to be returned.  I've tried to use the mktime function, but am at a loss so far.  What do I need to do?  Here's what I have so far.

 

$time = time();
$nmonth = time("+1 Month");

 

If you do it that way, you have the potential to end up with a month 13, which it will probably understand as 1 plus one year, but maybe not. Your best bet is to use strtotime.

 

You don't even need the time() function like in your code...just strtotime().  It implicitly uses 'now' as the default timestamp:

 

<?php
$nextmonth = strtotime('+1 month');
?>

It does. Complete operator error.  The calendar has two seperate $nmonth variables.  The first (which I overlooked) is for the Header Line and the second one is for the actual calendar.  Switched it and now works perfectly.  Thanks again!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.