logo

/Date Picker|v4.3.3

Class

new DateRangePicker(options)index.jsline 79

Create a date-range picker by DatePicker.createRangePicker().

PARAMETERS
NameTypeDescription

options

object

DateRangePicker options

PROPERTIES
NameTypeDescription

startpicker

object

Startpicker options

PROPERTIES
NameTypeDescription

input

HTMLElementstring

Startpicker input element or selector

container

HTMLElementstring

Startpicker container element or selector

date

[ Datenumber ]

Initial date of the start picker. Set by a Date instance or a number(timestamp). (default: no initial date)

weekStartDay

string = 'Sun'

Start of the week. 'Sun', 'Mon', ..., 'Sat'(default: 'Sun'(start on Sunday))

endpicker

object

Endpicker options

PROPERTIES
NameTypeDescription

input

HTMLElementstring

Endpicker input element or selector

container

HTMLElementstring

Endpicker container element or selector

date

[ Datenumber ]

Initial date of the end picker. Set by a Date instance or a number(timestamp). (default: no initial date)

weekStartDay

string = 'Sun'

Start of the week. 'Sun', 'Mon', ..., 'Sat'(default: 'Sun'(start on Sunday))

type

'date''month''year' = 'date'

DatePicker type. Determine whether to choose a date, month, or year.

language

string = 'en'

Language code. English('en') and Korean('ko') are provided as default. To use the other languages, use DatePicker.localeTexts.

timePicker

[ objectboolean ]

TimePicker options. Refer to the TimePicker instance's options. To create the TimePicker without customization, set to true.

calendar

[ object ]

Calendar options. Refer to the Calendar instance's options.

format

string = 'yyyy-mm-dd'

Format of the Date string

selectableRanges

[ Array ]

Ranges of selectable date. Set by Date instances or numbers(timestamp).

showAlways

boolean = false

Show the DateRangePicker always

autoClose

boolean = true

Close the DateRangePicker after clicking the date

usageStatistics

boolean = true

Send a hostname to Google Analytics (default: true)

EXAMPLES
// ES6
import DatePicker from 'tui-date-picker'

// CommonJS
const DatePicker = require('tui-date-picker');

// Browser
const DatePicker = tui.DatePicker;

const rangePicker = DatePicker.createRangePicker({
    startpicker: {
        input: '#start-input',
        container: '#start-container'
        date: new Date(2019, 3, 1),
        weekStartDay: 'Mon',
    },
    endpicker: {
        input: '#end-input',
        container: '#end-container',
        weekStartDay: 'Mon',
    },
    type: 'date',
    format: 'yyyy-MM-dd'
    selectableRanges: [
        [new Date(2017, 3, 1), new Date(2017, 5, 1)],
        [new Date(2017, 6, 3), new Date(2017, 10, 5)]
    ]
});

Instance Methods

addRange(start, end)index.jsline 427

Add a selectable range. Use Date instances or numbers(timestamp).

PARAMETERS
NameTypeDescription

start

Datenumber

the start date

end

Datenumber

the end date

changeLanguage(language)index.jsline 448

Change language.

SEES
PARAMETERS
NameTypeDescription

language

string

Language code. English('en') and Korean('ko') are provided as default.

destroy()index.jsline 456

Destroy the date-range picker.

getEndDate()index.jsline 401

Return the end date.

RETURNS:
{

Date

}

getEndpicker()index.jsline 377

Return a end-datepicker.

RETURNS:
{

DatePicker

}

getStartDate()index.jsline 393

Return the start date.

RETURNS:
{

Date

}

getStartpicker()index.jsline 369

Return a start-datepicker.

RETURNS:
{

DatePicker

}

removeRange(start, end, type)index.jsline 438

Remove a range. Use Date instances or numbers(timestamp).

PARAMETERS
NameTypeDescription

start

Datenumber

the start date

end

Datenumber

the end date

type

null'date''month''year'

Range type. If falsy, start and end values are considered as timestamp

setEndDate(date)index.jsline 409

Set the end date.

PARAMETERS
NameTypeDescription

date

Date

End date

setRanges(ranges)index.jsline 417

Set selectable ranges.

PARAMETERS
NameTypeDescription

ranges

Array.<Array.<numberDate>>

Selectable ranges. Use Date instances or numbers(timestamp).

setStartDate(date)index.jsline 385

Set the start date.

PARAMETERS
NameTypeDescription

date

Date

Start date

Events

change:endindex.jsline 288

Occur after the end date is changed.

SEES
EXAMPLES
// bind the 'change:end' event
rangePicker.on('change:end', () => {
    console.log(`End date: ${rangePicker.getEndDate()}`);
});

// unbind the 'change:end' event
rangePicker.off('change:end');

change:startindex.jsline 264

Occur after the start date is changed.

SEES
EXAMPLES
// bind the 'change:start' event
rangePicker.on('change:start', () => {
    console.log(`Start date: ${rangePicker.getStartDate()}`);
});

// unbind the 'change:start' event
rangePicker.off('change:start');
Resizable