Convert UTC Datetime Into Human Readable Format - UTC-time
File Size: | 22.7 KB |
---|---|
Views Total: | 2627 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
The UTC-time jQuery plugin automatically converts ISO formatted UTC time (last 60 days) into a human readable, auto updating string: x days/hours/minutes/seconds ago.
How to use it:
1. Insert the minified version of the jQuery UTC-time plugin after jQuery.
<script src="/path/to/cdn/jquery.slim.min.js"></script> <script src="/path/to/dist/jquery-utc-time.min.js"></script>
2. Insert the UTC time into the data-utc-time
attribute.
<p data-utc-time="01/15/2020 05:00:00 AM"></p>
3. Initialize the jQuery UTC-time plugin and done.
new UtcTime({ daysAgo: ' Days Ago', hoursAgo: ' Hours Ago', minutesAgo: ' Minutes Ago', secondsAgo: ' Seconds Ago' });
4. This will output the human readable time in the p
.
<p data-utc-time="01/15/2020 05:00:00 AM"> 31 hours ago </p>
5. If the the number of days you provide is greater than 60 days:
<!-- Converts ... --> <p data-utc-time="11/7/2017 05:00:00 AM"></p> <!-- Into ... --> <p data-utc-time="11/7/2017 05:00:00 AM"> 2017/11/7 </p>
6. Change the default data
attribute:
new UtcTime({ attr: 'data-utc-time' });
7. Customize the date format:
new UtcTime({ format: 'yyyy MM dd hh:mm:ss', });
8. More configurations.
new UtcTime({ disableAgo: false, onSet: function (obj) { }, disableAutoUpdate: false });
Changelog:
2023-07-28
- v2.1.1
2020-05-17
- v2.0.0
2020-01-22
- v1.3.11: Bugfix
2020-01-16
- v1.3.9
2019-08-05
- v1.3.8: Support init once.
2019-06-10
- v1.3.6: More bugs fixed
2019-04-26
- v1.3.3: Support new forceInitUTCTime
2019-01-25
- v1.3.2: Fix an issue.
2019-01-10
- v1.3.0: support more features.
2018-12-07
- Bugfix
2018-12-06
- v2.1.0
This awesome jQuery plugin is developed by Anduin2017. For more Advanced Usages, please check the demo page or visit the official website.