• I have a particular task that I have to do once a month, every month. A friend of mine created a hack for me that reminds me of the task and how many days are left in the month to perform the task. This hack also accounts for leap years. I figured out that the way it was coded was removing the names of the months from the dates that appeared above my posts (so that the dates were appearing as “1 2004 (Saturday)” instead of as “1 July 2004 (Saturday). My friend adjusted the code a little bit for me so that now it works better. Here is the code that I place in the my-hacks.php file. The call that needs to be placed in the index.php file is farther below.
    <?php
    $today = date( “j” );
    $ht_month = date( “n” );
    if ( $ht_month == 4 || $ht_month == 6 || $ht_month == 9 || $ht_month == 11 )
    {
    $max = 30;
    }
    else if ( $ht_month == 2 )
    {
    $max = ( date( “L” ) == 1 ) ? 29 : 28;
    }
    else
    {
    $max = 31;
    }
    $left = ( $max – $today );
    $left = ( $left == 1 ) ? “is $left day” : “are $left days”;
    ?>
    The call (placed in index.php wherever you want it to show up, with whatever reminder message you wanted):
    There <?php print $left; ?> left to earn next month’s rent.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 2 years old I know, just kicking it out of the “no-replies” section.. Also, I’m not sure if this “hack” is still technically valid or not.. Kaf should/would know.

    And I’m not sure if there has been a plugin made, on this same thing either.. =/ Being that I don’t use any monthly related plugins per se… I’ll leave this open for PHP professionals to comment on it..

    And, if need be.. if other mods want to [Close] this.. then that’s cool too! ??

    spencerp

    /So, DO NOT try this “hack” if I were you, unless you’re a PHP PRO, and know what you’re doing!! Or, unless other wise confirmed by a PHP PRO, or Moderator with PHP experience!!

    I think the new wp-cron module in WordPress 2.1 would do the job for you now.

    Hmmm.. I haven’t really messed with my 2.1 test blog lately.. have it updated for the most part though.. I’ll have to mess with it more when I have time.. =P

    Again, no one should really use this “hack” if they don’t know what they are doing.. and this still should be confirmed by Kaf, or another PHP PRO..

    spencerp

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘days left in the month hack’ is closed to new replies.