https://github.com/wassimbj/nta
Simple, lightweight JS Time Ago module
https://github.com/wassimbj/nta
date javascript multilingual nta timeago
Last synced: 5 months ago
JSON representation
Simple, lightweight JS Time Ago module
- Host: GitHub
- URL: https://github.com/wassimbj/nta
- Owner: wassimbj
- License: mit
- Created: 2019-11-24T13:46:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T03:34:43.000Z (over 3 years ago)
- Last Synced: 2025-09-28T04:59:43.444Z (9 months ago)
- Topics: date, javascript, multilingual, nta, timeago
- Language: JavaScript
- Homepage:
- Size: 87.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGE_LOG.md
- License: LICENSE
Awesome Lists containing this project
README
## What is this ?
This is a simple lightweight **JS Time Ago module**,
that supports different languges and you can contribute to add yours.
## works on the browser and server
if you want to use it on the **browser**, you must include the `nta.min.js` file into you html file
else if you are using **server side rendering or any js framework**, just npm install it and import it as you import any other package
## Languages available for now are:
`ar: arabic, en: english, de: german, vn: vietnamese`
**please note that the default language is arabic, if you dont specifiy it in the second argument it will display in arabic language**
## Display formats
```javascript
// ago format, this is the default format
timeAgo('2020-01-16 19:48:45', 'en'); // will return: 3mo ago
// full format
timeAgo('2020-01-01 19:48:45', 'en', 'full'); // will return: 1 January
```
## Usage
after installing `nta`
```javascript
const timeAgo = require('nta');
timeAgo(new Date, 'en', 'ago')
```
***params***
timeAgo function accepts 3 parameter wich are the `date, language, format`.
**the language is not required, arabic is set by default**
**the format is not required too, "ago" is set by default**
## Accessible to your views ?
```javascript
app.locals.timeAgo = timeAgo
```
Thats is it, nta is now accessible to all of your views you can use it as specified above.
**Dont Forget to contribute by adding your language or any other feature you like**