Keep your résumé dates current automatically with jQuery

You can easily create dynamically updating dates in your pages with jQuery.† I actually use Template Toolkit to keep the dates accurate in my résumé. It’s better to do it that way—build static content based on dynamic information—because the automated web agents that recruiters use are less likely to understand JavaScript. Before discounting that advice know that I’ve had 6 recruiters write me out of the blue this Summer and it wasn’t from my awesome networking abilities.

This is a bit of a puff piece as you’ll have to adapt the code somewhat to use for your own page. Still, this is fun, easy and can be adapted to a number of other applications. Think “member since” or displaying dates and times in the user’s local time instead of your server’s.

Click here to convert dates

Since 2012 · Mayan High Priest.

Since 2009 · Proprietor, Man-Pops, International.

Since 2008 · Merchandising Director of something equally dirty.

Since 2007 · Monkey spanker.

Since 1998 · Proprietor, Sedition·com.

Since like forever · Super Genius.

You’ll have to put your dates into some kind of container to find them easily unless you want to do some monster slow parsing of the text. We went with the class “since” in <b/>s but you can do it however you like for your page. Here is what the above entries look like raw–

<p><b class="since">Since 1998</b> · Proprietor, Sedition·com.</p>

And the code. Note the ternary operator we use to get “1 year” versus “2 years” correct.

The jQuery + helper function

  // Compute thisYear up front.
  var now = new Date;
  var thisYear = now.getFullYear();
  function getYearsEx (year) {
     var diff = thisYear - year;
     if ( ! year || diff < 0 || isNaN(diff) )
     {
         return "No experience";
     }
     else if ( diff == 0 )
     {
         return "Less than a year";
     }
     else
     {
         return diff + " year" +
               ( diff == 1 ? "" : "s" );
     }
  }

  $(".since").each(function(){
                    $(this).fadeOut(function(){
                        var year = $(this).text().replace(/\D+/g,"");
                        var yearsEx = getYearsEx(year);
                        $(this).text(yearsEx);
                        $(this).fadeIn();
                     })
                   });
  });

And the TT2 version just for fun–

[% USE date %]
[% this_year = date.format(date.now, '%Y') %]
<p>
  [% this_year - 1998 %] years as proprietor of Sedition·com.
</p>
<p>
  [% this_year - 2007 %] year[% "s" IF this_year > 2008 %] with jQuery
</p>
† The big caveat being, your date display is tied to the system clock of the viewer’s computer and browser. Most everyone online has their time set automatically and correctly but you never know what recruiter might see your résumé with a broken Windows installation that chops 5 years off all your experience.
digg stumbleupon del.icio.us reddit Fark Technorati Faves
Your information (required) Name*
Email*
Website

* Indicates required fields; email is used for validation and is not displayed on the site.

Your comment
Commenting on Keep your résumé dates current automatically with jQuery
Title

Body is limited to ≈1,000 words. Paragraphs—but not line breaks—are automatically inserted. Valid XHTML is required. These are the allowed tags–

<a href=""></a> <br/> <acronym title=""></acronym> <abbr title=""></abbr> <code></code> <pre></pre> <tt></tt> <ins></ins> <del></del> <hr/> <cite></cite> <b></b> <i></i> <sup></sup> <sub></sub> <strong></strong> <em></em> <h1></h1> <h2></h2> <h3></h3> <q></q> <blockquote></blockquote>