2.1.1 • Published 11 months ago

jquery-utc-time v2.1.1

Weekly downloads
101
License
MIT
Repository
gitlab
Last release
11 months ago

jQuery-UTC-time

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

npm

How to install

Download from NPM

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/dist/jquery-utc-time.min.js"></script>

Or using es6:

import UtcTime from 'jquery-utc-time';

Use via CDN

Add your reference:

<script src="https://ui.cdn.aiursoft.com/node_modules/jquery-utc-time/dist/jquery-utc-time.min.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>
    new UtcTime({ });
</script>

And open it now! The time will be converted to local time.

API

    // Init with loop
    new UtcTime({
        // 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,

        // After the content is replaced.
        onSet: function(element) { },

        // Disable auto update the value by seconds.
        disableAutoUpdate: false
    });

For example, to init bootstrap tooltip:

new UtcTime({
    onSet: function(element) {
        $(element).tooltip();
    }
});
2.1.1

11 months ago

2.0.2

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.11

4 years ago

1.3.10

4 years ago

1.3.9

4 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago