jquery-utc-time

jquery-disable-with is a jQuery plugin which converts UTC time to local time easily.

jquery-utc-time example

jquery-disable-with is a jQuery plugin which converts UTC time to local time easily.

Running Example

Page render time

Two minutes before page render

Two hours before page render

Two days before page render

Source Code
<h4>Page render time</h4>
<label data-utc-time="2/19/2019 5:42:06 PM">

</label>

<h4>Two minutes before page render</h4>
<label data-utc-time="2/19/2019 5:40:06 PM">

</label>

<h4>Two hours before page render</h4>
<label data-utc-time="2/19/2019 3:42:06 PM">

</label>

<h4>Two days before page render</h4>
<label data-utc-time="2/17/2019 5:42:06 PM">

</label>
Document

jQuery-UTC-time

A jquery plugin which converts UTC time to local time easily.

npm

How to install

$ npm install jquery-utc-time

And add your reference:

<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/jquery-utc-time/src/jquery-utc-time.js"></script>

How to use

Create an element.

<p>

</p>

And change it like this.

<p data-utc-time="9/12/2018 10:12:24 AM"><!-- In your tag the time shall be an UTC time -->
  
</p>

Add init jquery-utc-time

<script>
    $(this).initUTCTime({ });
</script>

And when it starts, it shows like this.

jquery-utc-time running

API

    $(this).initUTCTime({
        // We will try to select elements using the attr value. Default value is 'data-utc-time'.
        attr: 'data-utc-time',

        // We the given time is later than now, we will replace the value to its local time using the format. If format is not specified, we will just convert it to local string.
        format: 'yyyy年 MM月 dd日 hh:mm:ss',

        // Localization options. Default is ' days ago'
        daysAgo: '天前',

        // Localization options. Default is ' hours ago'
        hoursAgo: '小时前',

        // Localization options. Default is ' mintes ago'
        minutesAgo: '分钟前',

        // Localization options. Default is ' seconds ago'
        secondsAgo: '秒前',

        // Always display time and date not `some time` ago.
        disableAgo: false
    });
View it on github
;