how to set am/pm format in jquery using datetimepicker

后端 未结 8 1269
孤独总比滥情好
孤独总比滥情好 2021-01-18 09:14

this is my jquery code.eventdatpicker is display date only,but occasionStartTime and occasionEndTime it display 24 hours format only how to change this format to am/pm forma

相关标签:
8条回答
  • 2021-01-18 09:31
    $('#StartDate').datetimepicker(
                    {
                        format: 'DD MMM YYYY hh:mm A'
    
                    });
    

    where startDate is a divId

        <div class="input-group date form_datetime" id="StartDate">
             <input type="text" class="form-control input-lg" placeholder="From" name="StartDate" id="txtStartDate" required /> 
    <span class="input-group-addon">
    <span class="glyphicon-calendar glyphicon"></span></span>
     </div>
    

    This will give you format like: 25 Mar 2016 01:08 PM

    0 讨论(0)
  • 2021-01-18 09:34

    in nowdays version, 2021 / 1 / Jan you have to type in e.g.:

            $('#dateTimePicker').datetimepicker({
                .....,
                formatTime:'g:iA',
                format: 'Y.m.d hh:mm A',
                .....
            }
    

    And you are done

    0 讨论(0)
  • 2021-01-18 09:39

    Use this plugin to unobtrusively add a datetimepicker, datepicker or timepicker dropdown to your forms. It's easy to customize options.

    You can download Plugin: Download

    add js and css to head tag:

    <link rel="stylesheet" type="text/css" href="./js/jquery.datetimepicker.css" />
    <script src="./js/jquery.datetimepicker.js"></script>
    

    add this code to you want show:

    $(function () {
        $('#video_schedule').datetimepicker({
            step:5,
            minDate:0,
            formatTime:'H:i'
        });
    });
    
    0 讨论(0)
  • 2021-01-18 09:40
    $('#occasionStartTime').datetimepicker({
            format: 'Y/m/d A g:i',
            formatTime: 'A g:i',
        });
    
    0 讨论(0)
  • 2021-01-18 09:40

    If you've only got a time field instead of a datetime field - you can set AM/PM format using

     $("#yourTimeField").timepicker({
            showPeriod: true
     });
    
    0 讨论(0)
  • 2021-01-18 09:41

    Try

    $('#occasionStartTime').datetimepicker({
        datepicker : false,
        ampm: true, // FOR AM/PM FORMAT
        format : 'g:i A'
    });
    
    0 讨论(0)
提交回复
热议问题