https://github.com/anduin2017/jquery-utc-time
A jQuery plugin which converts UTC time to local time easily.
https://github.com/anduin2017/jquery-utc-time
Last synced: about 1 year ago
JSON representation
A jQuery plugin which converts UTC time to local time easily.
- Host: GitHub
- URL: https://github.com/anduin2017/jquery-utc-time
- Owner: Anduin2017
- License: mit
- Created: 2018-10-22T14:05:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-01-02T17:44:23.000Z (over 1 year ago)
- Last Synced: 2025-04-01T23:35:52.537Z (about 1 year ago)
- Language: HTML
- Homepage: https://developer.aiursoft.com/Samples/UTCTime
- Size: 426 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jQuery-UTC-time
A jquery plugin which converts UTC time to local time easily.
[](https://www.npmjs.com/package/jquery-utc-time)
[](https://gitlab.aiursoft.cn/anduin/jQuery-UTC-time/-/commits/master?ref_type=heads)
## How to install
### Download from NPM
```bash
npm install jquery-utc-time
```
And add your reference:
```html
```
Or using es6:
```javascript
import UtcTime from 'jquery-utc-time';
```
### Use via CDN
Add your reference:
```html
```
## How to use
Create an element.
```html
```
And change it like this.
```html
```
Add init jquery-utc-time
```html
new UtcTime({ });
```
And open it now! The time will be converted to local time.
## API
```javascript
// 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:
```javascript
new UtcTime({
onSet: function(element) {
$(element).tooltip();
}
});
```