Examples

Basics

A timepicker in the simplest fashion.

$('#ex_basic_1').intimidatetime();

Add a few options, change the format. Intimidate time detects which time units are needed by the format.

$('#ex_basic_2').intimidatetime({
	format: 'MMM d, yyyy'
});

Use the preview format, this is useful when you need to generate a Unix timestamp.

$('#ex_basic_3').intimidatetime({
	format: 'u',
	previewFormat: 'yyyy-MM-dd HH:mm:ss'
});

You can add on extra functionality by using buttons. Pass an array of as many as you like.

var $basicEx4 = $('#ex_basic_4').intimidatetime({
	buttons: [
			{ 
				text: 'Done', 
				action: function(e){ $basicEx4.intimidatetime('close'); return false; } 
			},
			{ 
				text: 'Now', 
				action: function(e){ $basicEx4.intimidatetime('value', new Date() ); return false; }
			}
		]
});

You can change input types using the units.{unit type}.type option.

$('#ex_basic_5').intimidatetime({
	format: 'MMM yyyy',
	units: {
		year: { type: 'list', options: [2013,2014,2015] },
		month: { type: 'list', format: 'MMMM' }
	}
});

Timezones

You can enable timezones with the "z" format token.

$('#ex_timezone_1').intimidatetime({
	format: 'yyyy-MM-dd HH:mm z'
});

Suppose you want the user to have more readable timezone descriptions, but behind the scenes Intimidate time needs the numeric timezone. We can pass a few timezone options.

The option values must be minute offsets from utc. Just like Date.getTimezoneOffset() the offset for -0400 is 240. Intimidatetime tries to follow the path laid by javascript. Then You can assign names to each value.

$('#ex_timezone_2').intimidatetime({
	format: 'yyyy-MM-dd HH:mm zzz',
	units: {
		timezone: {
			format: 'zzz',
			options: [240,300,360,420],
			names: {
				"240": "EDT", 
				"300": "CDT", 
				"360": "MDT",
				"420": "PDT"
			}
		}
	}
});

Ranges

Ranges are very simple, just use the range option.

$('#ex_ranges_1').intimidatetime({
	ranges: 1
});

Sometimes maybe you don't want a range necessarily, but a list of dates. Use the rangeDelimiter and range options together. Here we request 3 dates.

$('#ex_ranges_2').intimidatetime({
	format: 'yyyy-MM-dd',
	ranges: 2,
	rangeDelimiter: ', '
});