Add custom text to the output text field in bootstrap datetimepicker

前端 未结 2 1091
面向向阳花
面向向阳花 2020-12-21 06:19

I\'m using bootstrap 3 date/time picker here:

https://eonasdan.github.io/bootstrap-datetimepicker/

Is it possible to customise the output text in the date/ti

2条回答
  •  鱼传尺愫
    2020-12-21 06:51

    You have to use square brackets in your format option, because the component uses moment tokens.

    Moment docs has an Escaping characters section which states:

    To escape characters in format strings, you can wrap the characters in square brackets.

    moment().format('[today] ffffdd'); // 'today Sunday'
    

    Here is a working sample:

    $('#datetimepicker').datetimepicker({
      defaultDate:'now',
      ignoreReadonly: true,
      format: '[Departing:] DD/MM/YYYY HH:mm:ss'
    });
    
    
    
    
    
    
    
    
    

提交回复
热议问题