Ekata
Ekata

Reputation: 289

Setting date and time format for Bootstrap date time picker

Im using bootstrap datetime picker Bootstarp picker

how can i change default date and time format.

I have tried dateFormat: 'dd-mm-yy', format: 'yyyy-mm-dd hh:ii',dateFormat: 'yymmdd' in

 $('.datetimepicker').datetimepicker({
 dateFormat: 'yymmdd',
 timeFormat: 'hhmm'
 });
 

But none of them seem to work. Please help i want change the dateFormat to yy-mm-dd and time format to HH:mm:ss

Upvotes: 0

Views: 9416

Answers (3)

pubudu sachintha
pubudu sachintha

Reputation: 763

Try like below

 $('.datetimepicker').datetimepicker({
 format: 'yyyy-dd-mm',
 });

Upvotes: 0

Chris Ringrow
Chris Ringrow

Reputation: 1

YYYY-MM-DD hh:mm:ss did not work for me.

The following did though:

$( function() {$( "#datetimepicker" ).datetimepicker({ format: "d-m-y H:i" });} );

Upvotes: 0

Jason Tate
Jason Tate

Reputation: 716

You will need to set the format option with a valid moment format

$('.datetimepicker').datetimepicker({
    format: 'YYYY-MM-DD hh:mm:ss'
});

Upvotes: 1

Related Questions