Maybe you saw the video about my blunder?

 

My iMember360 custom shortcodes training video error

 

iMember360 Custom ShortcodeIf you did, I hope you enjoyed me poking fun at myself.  It wasn't quite as horrible a blunder as I made it out, but I did want to get peoples attention regarding my FirstOfNextMonth custom shortcode and the error.  I didn't notice that there was an issue until it got to the very end of the month.  I made an assumption (yes I know the saying and believe me that was NOT my intention) about the operation parameter of "+1 months"

What made it not work?

 

day1nextmonthMy assumption was that it would add a month, and in so doing would merely increment the "m" in the date format expressed as "m/d/Y" but much to my surprise it appears as though it just adds 30 days.  So When you are in a month with 31 days, and the following month only has 30 days, on the last day of your current month, you get a very BAD result for your first day of the next month.  The custom shortcode actually returns the first day of the month for the month AFTER next.  That resulted in any of the countdown timers that were dependent on that custom shortcode showing a countdown that was one month longer than intended.  NOT GOOD!

How did I fix it?

 

I ended up rethinking the shortcode and instead of using the "operations" parameter in the i4w_date shorcode, I manipulated some string characters using i4w_exec shortcode (to enable PHP in the content) and used the i4w_set command to set some variables.  I then used the i4w_compare to account for the end of the year when the incrementing of the current month would return a 13 and the year would be incorrect.  I won't have time to create the video training to explain all the steps and logic in the shortcode, so what I thought I would do is copy the custom shortcode into the post so you could easily download it and replace the old custom shortcode that you may have made based on my incorrect assumption.

New iMember360 custom shortcode - OneSecondAfterEndOfMonth

OneSecondAfterEndOfMonth

Click to Download Source Code

Here's the video if you would like to watch.

 

In case you are interested, it's using the YouTube Responsive Player custom shortcode that was recently added to the Advanced Level Training modules.

Get FREE Advanced Training for iMember360

Comments

comments

Pin It on Pinterest

Shares
Share This