vue-date-now
Easily work with dates using the available methods.
Feel free to collaborate. I would like to expand translations, so if you dare! 🚀
Install with npm:
npm install vue-date-now
or install with yarn
yarn add vue-date-now
Enable it in your project:
; Vue;
Use the available methods:
name: 'app' { return year: this$dn monthText: this$dn }
Documentation
Notes:
This documentation has been created on 2019-06-17.
The monthText method supports all languages thanks to the toLocaleString() method of js
Languages available for howLong and dayText methods:
Slug | Language |
---|---|
es | Spanish |
en | English |
Methods
@ date()
# Parameters (3)
1. # date
- Required: false
- Type: Date Object
- Default: new Date()
- Description: You can specify the date by passing this parameter with an instance of the Date object.
2. # format
- Required: false
- Type: String
- Default: 'yyyy-mm-dd'
- Description: You can specify the format by passing it a string.
3. # separator
- Required: false
- Type: String
- Default: '/'
- Description: You can specify the separator by passing it a string.
$ How to use
this$dn // result = 17-06-2019this$dn // result = 17/06/2019this$dn // result = 2019/06/17this$dn // result = 2019/06/17
@ howLong()
# Parameters (2)
1. # date
- Required: true
- Type: Date Object || date String || timestamp String
- Description: It is required to specify the date to obtain the time since then.
2. # language
- Required: false
- Type: String
- Default: 'en'
- Description: You can specify the language by passing it a string.
$ How to use
this$dn // result = A few months agothis$dn // result = More than a year agothis$dn // result = Hace unas horas
@ year()
# Parameters (1)
1. # date
- Required: false
- Type: Date Object || date String || timestamp String
- Default: ''
- Description: You can specify the date by passing this parameter with an instance of the Date object.
$ How to use
this$dn // result = 2019this$dn // result = 2016this$dn // result = 2014this$dn // result = 2019
@ month()
# Parameters (1)
1. # date
- Required: false
- Type: Date Object || date String || timestamp String
- Default: ''
- Description: You can specify the date by passing this parameter with an instance of the Date object.
$ How to use
this$dn // result = 06this$dn // result = 04this$dn // result = 02this$dn // result = 06
@ monthText()
# Parameters (2)
1. # date
- Required: false
- Type: Date Object || date String || timestamp String
- Default: ''
- Description: You can specify the date by passing this parameter with an instance of the Date object.
2. # language
- Required: false
- Type: String
- Default: 'en'
- Description: You can specify the language by passing it a string.
$ How to use
this$dn // result = Junethis$dn // result = Enerothis$dn // result = Marzothis$dn // result = Junethis$dn // result = June
@ day()
# Parameters (1)
1. # date
- Required: false
- Type: Date Object || date String || timestamp String
- Default: ''
- Description: You can specify the date by passing this parameter with an instance of the Date object.
$ How to use
this$dn // result = 2this$dn // result = 6this$dn // result = 3this$dn // result = 2
@ dayText()
# Parameters (2)
1. # date
- Required: false
- Type: Date Object || date String || timestamp String
- Default: ''
- Description: You can specify the date by passing this parameter with an instance of the Date object.
2. # language
- Required: false
- Type: String
- Default: 'en'
- Description: You can specify the language by passing it a string.
$ How to use
this$dn // result = Mondaythis$dn // result = Viernesthis$dn // result = Sábadothis$dn // result = Mondaythis$dn // result = Monday
@ diff()
# Parameters (3)
1. # date
- Required: true
- Type: Date Object || date String || timestamp String
- Description: It is required to specify the most current date of the comparison.
2. # date
- Required: true
- Type: date String || timestamp String
- Description: It is required to specify the oldest date of comparison.
3. # type
- Required: false
- Type: String
- Default: 'days'
- Available values: 'seconds', 'minuts', 'hours', 'days', 'weeks', 'months', 'years'
- Description: You can specify the type of data to return.
$ How to use
this$dn // result = 2.8this$dn // result = 31.2this$dn // result = 936.0
@ time()
# Parameters (0)
0. # without parameters
$ How to use
this$dn // result = 18:31:48