Convert UTC Datetime Into Human Readable Format - UTC-time

Convert UTC Datetime Into Human Readable Format - UTC-time
File Size: 5.06 KB
Views Total:
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="https://code.jquery.com/jquery-3.3.1.slim.min.js" 
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 
        crossorigin="anonymous">
</script>
<script src="dist/jquery-utc-time.min.js"></script>

2. Insert the UTC time into the data-utc-time attribute.

<p data-utc-time="11/07/2018 05:00:00 AM"></p>

3. Initialize the jQuery UTC-time plugin and done.

$(this).initUTCTime({
  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="11/7/2018 05:00:00 AM">
  24 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>

Changelog:

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.