jQuery Plugin To Parse Human Readable Datetime - jTimeMachine
| File Size: | 8.26 KB |
|---|---|
| Views Total: | 480 |
| Last Update: | |
| Publish Date: | |
| Official Website: | Go to website |
| License: | MIT |
jTimeMachine is a jQuery plugin that prints out the passed times or pending times in human readable strings and keeps them corrects compared to now.
How to use it:
1. Include jQuery library and the jQuery jTimeMachine plugin on the webpage as usual.
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script> <script src="dist/jTimeMachine.min.js"></script>
2. Insert the timestamps into the 'data-date' attribute as follows.
I am <span id="demo-1" data-date="01/01/1990"></span> years old How long 'til Next Christmas? <span id="demo-2" data-date="2016/12/25"></span> days
4. Initialize the plugin.
$('#demo-1').jTimeMachine();
$('#demo-2').jTimeMachine({
return: 'day'
});
5. This will output...
I am 25 years old How long 'til Next Christmas? 391 days
6. Output the relative time in full mode.
$('#demo').jTimeMachine({
return:'full'
});
7. Customize the datetime strings.
$('#selector').jTimeMachine({
dictYears: 'years',
dictYear: 'year',
dictMonth: 'month',
dictMonths: 'months',
dictWeek: 'week',
dictWeeks: 'weeks',
dictDay: 'day',
dictDays: 'days',
dictHours: 'hours',
dictHour: 'hour',
dictMinutes: 'mins',
dictMinute: 'min',
dictSeconds: 'secs',
dictSecond: 'sec'
});
This awesome jQuery plugin is developed by oliver-j. For more Advanced Usages, please check the demo page or visit the official website.











