3

I am using bootstrap datetimepicker. I want the datetimepicker format as short month name eg. Jan. My code is below and it shows the full month name now as January. How to make it Jan?

$('.datepickersren').datetimepicker({             
    format: 'MMMM',
    viewMode: "months", 
})

Please note that the format:'M' is not working in datetimepicker. It will work on the datepicker only. If we give format:'M' in datetimepicker, the month format is month number eg. 5, 6, 7 etc. Not the month names like Jan, Feb, etc.

VincenzoC
  • 30,117
  • 12
  • 90
  • 112
Nuju
  • 322
  • 6
  • 17
  • $('.datepickersren').datepicker({ dateFormat: 'dd-M-yy' }); – JYoThI May 05 '17 at 04:17
  • Possible duplicate of [how can i format jquery datepicker as "25-JAN-2009"](http://stackoverflow.com/questions/2057157/how-can-i-format-jquery-datepicker-as-25-jan-2009) – JYoThI May 05 '17 at 04:18
  • For datetimepicker, format: 'M' is not working. – Nuju May 05 '17 at 05:15

2 Answers2

2
$('.datepickersren').datetimepicker({             
    format: 'MMM',
    viewMode: "months", 
})

The above code is working for me and the format: 'MMM' displays the three letter month name as Jan, Feb etc. Thank you all for the response.

VincenzoC
  • 30,117
  • 12
  • 90
  • 112
Nuju
  • 322
  • 6
  • 17
  • It works because eonasdan-datetimepicker uses moment and as moment [docs says](http://momentjs.com/docs/#/displaying/format/) `MMM` stands for `Jan`, `Feb`, ..., `Nov`, `Dec`. – VincenzoC May 05 '17 at 08:58
1

A single M is "Month name short"

      $('.datepickersren').datetimepicker({             
          format: 'dd-M-yy',
          viewMode: "months", 
      })
Ali Niaz
  • 312
  • 3
  • 10