Human friendly time parses with tidytime.js

Have you ever feel bored with standard time format like 08:30? Do you want time strings that looks great? Now you can do it with tidytime.js. Tidytime.js is a jQuery plugin that transforms standard time notation to something that’s human-friendly.

tidytime-demo

As you can see, it can transform standard time notation into human-friendly parses. Isn’t it great? Let’s see how to use this great plugin.

First, you need to include jQuery & tidytime.js.

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="tidyTime.js"></script>

After that, create an element that holds the time.

<span class="tidytime"></span>

The easiest way to use tidytime.js is to call it with no options.

$(document).ready(function ($) {
    $('.tidytime').tidyTime();
});

If you want to call it with options, you can do it like this:

$('.tidytime').tidyTime({
    time: '08:15', //The time string in hh:mm format
    before: 'It\'s ', //The string appended before tidytime string
    after: ' and I\'m feeling good!', //The string appended before tidytime string
    periodOfDay: true, //Show parses like 'in the morning', 'in the afternoon', 'in the evening' and 'at night'
    callback: tidyTimeFunction //The name of the function that you would like pass as a callback once the time has been updated
});

Additional details can be found at http://git.aaronlumsden.com/tidytime.js/.

Leave a Reply

Your email address will not be published. Required fields are marked *