A seldom-used tag is the <ins /> tag. The tag is used to mark content that has been inserted later. For example:
<ins datetime="2004-11-01T04:36:0105:00">This was added later</ins>
The datetime
parameter should reflect the date and time when the material was inserted. Those of you using WordPress can have that date generated for you automatically. Just highlight the updated content, and click the “ins” Quicktag button.
While this is nice, it doesn’t really convey any information to people viewing your site. This information is locked away in the <ins /> tag. So here is what I do to unleash that information.
I have this in my my-hacks.php
file.
function htmldate_to_unix($date){ $date = mktime(substr($date, 11, 2), substr($date, 14, 2), substr($date, 17, 2), substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4)); return $date; } function fancy_inserts_callback($matches){ $date = htmldate_to_unix($matches[1]); $output = '<ins datetime="' . $matches[1] . '" title="Updated: ' . date("F j, Y, g:i a", $date) . '">'; return $output; } function fancy_inserts($text) { $ins_pattern = '/<ins datetime="(.*?)">/i'; $text = preg_replace_callback($ins_pattern, 'fancy_inserts_callback', $text); return $text; }
This code grabs the datetime
attribute from the <ins /> tags and converts it to a UNIX style timestamp which can easily be converted into an English-readable representation of the date. It then sticks that English-readable date into the title
attribute, so it shows on hover. I’ve also applied the following CSS.
ins { text-decoration:none; } ins:hover { background-color: #FAF5F5; cursor: e-resize; }
If you wanted, you could combine this with a “time passed” plugin, and have it display something like this:
This is my entry.
Update (30 minutes later): I have something else to say!