Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4605820
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:28:58+00:00 2026-05-22T00:28:58+00:00

I currently allow for daily or weekly repeating events on my calendar app (using

  • 0

I currently allow for daily or weekly repeating events on my calendar app (using fullCalendar).

My view has a checkbox that activates two dropdowns: one for the repeat interval (daily, weekly) and one for the frequency (once, twice, etc).

$evt_interval_options = array( //this will be $row->interval in the model
    '86400' => 'Daily',   
    '604800' => 'Weekly'; 

$evt_frequency_options = array(  //this will be //$i in the model
    '1' => '2',    
    '2' => '3',    

<?php echo form_checkbox('evt_repeat', 'FALSE', FALSE, 'class="repeat_checkbox"'); 
      echo form_dropdown('evt_interval', $evt_interval_options');
      echo form_dropdown('evt_frequency', $evt_frequency_options'); ?>

This eventually reaches my model, which runs a loop checking if the event should repeat — if so, it will factor in the interval ($row->interval) and the frequency ($i).

$cal_data[] = array(
    'start' => strtotime($row->date_1 . ' ' . $row->time_1) + ($i ? ($row->interval * $i) : 0),
);

This works nicely to show multiple daily or weekly events based on a single record entry in the database.

The problem is with monthly and yearly. Since these will have variable number of seconds because

03/01/2011 00:00:00 --> 04/01/2011 00:00:00 ===> 2674800 seconds
04/01/2011 00:00:00 --> 05/01/2011 00:00:00 ===> 2592000 seconds
and so on for monthly and yearly differences

So how do I resolve this issue? Is there any function or strtotime command that can help indicate precisely that a monthly should repeat on the e.g. 4th or an yearly should repeat on July 4th?

I am using PHP 5.2.14.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:28:59+00:00Added an answer on May 22, 2026 at 12:28 am

    Thanks to all that answered – I solved the issue with this function by @akniep from the PHP.net manual on strtotime().

    function get_x_months_to_the_future( $base_time = null, $months = 1 )
    {
        if (is_null($base_time))
            $base_time = time();
    
        $x_months_to_the_future    = strtotime( "+" . $months . " months", $base_time );
    
        $month_before              = (int) date( "m", $base_time ) + 12 * (int) date( "Y", $base_time );
        $month_after               = (int) date( "m", $x_months_to_the_future ) + 12 * (int) date( "Y", $x_months_to_the_future );
    
        if ($month_after > $months + $month_before)
            $x_months_to_the_future = strtotime( date("Ym01His", $x_months_to_the_future) . " -1 day" );
    
        return $x_months_to_the_future;
    }
    

    What this does is solve the issue of recurring monthly events on days 29, 30, 31 as well as Feb 28.

    I like this function because it solves my problem from a calendar app POV.

    If the user requests a monthly recurring event beginning on Jan 31 normal strtotime will behave erratically during February and any other month that does not have 31 days.

    As I pointed out in a comment above, Google Calendar resolves this issue somewhat oddly by skipping months in which there’s no such date.

    I guess it’s a matter of preference, but to me it makes better sense to offer placing the recurring event on the last day of the month – so in the Jan 31 example, recurring events will happen on Feb 28 Mar 31 Apr 30 and so on.

    I placed this function in a loop that iterates as many recurrences the user requests and it works perfectly. It also works nicely in yearly events, for that I just pass 12 as the number of months.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app that shows statistics based on an employee's daily production.
Currently there is a button on my app inteface which allow to open a
I am currently using Oauth to allow a user to sign in through Foursquare,
I am currently working on an iOS application that I allow the user to
Currently I have an edittext field that when the user presses enter it does
I currently have a coldfusion regex that checks whether a string is alphanumeric or
I'm currently using winforms databinding to wire up a data editing form. I'm using
Currently, db4o does not allow indexing on the contents of collections. What object databases
We are currently working on a defect to allow special symbols also to be
I'm currently writing a library where I wish to allow the user to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.