Convert 4 digit year to 2 digits

1357436200_schedule

At times I find myself a little handcuffed by CMS’s and third party modules or plugins. If you need to modify the results of a pre-existing solution or alter it’s function, typically the highest performing method to modify (i.e. hack) the solution’s underlying code.

Unfortunately this may cause problems in the future if the clients wants to upgrade, may have unintended effects, or might just not be feasible. I often run against these problems when unifying date format across diverse modules.  In one such recent case I used a DNN module that did not have a configurable option to format the year in a date as a two digit number.

To remedy this problem, I created some jQuery to find the year by grabbing the last four digits of the date text, store the last two digits of the year as a new variable, and find all instances of the old four digit year and replace them with the new shortened version.

Since this happens a bit after load it can potentially cause an observable anomaly, but if the page load is managed carefully, or the data is off screen, this is an effective and quick fix.

This entry was posted in Uncategorized.