skip to Main Content

I need to set a datetimepicker in the specific format dd/mm/yyyy hh:mm tt for example 13/03/2024 2.30 PM. But, I am getting 13/03/2024 14.30. I also can not set the minutes. It only shows the hours like 11.00, 12.00 and so on.

I tried in this way.
cdn links

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.css" integrity="sha512-bYPO5jmStZ9WI2602V2zaivdAnbAhtfzmxnEGh9RwtlI00I9s8ulGe4oBa5XxiC6tCITJH/QG70jswBhbLkxPw==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.min.js" integrity="sha512-AIOTidJAcHBH2G/oZv9viEGXRqDNmfdPVPYOYKGy3fti0xIplnlgMHUGfuNRzC6FkzIo0iIxgFnr9RikFxK+sw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

html

<input type='text' id='txtDateTimePicker' />

javascript

$(function () {
    $('#txtDateTimePicker').datetimepicker({
        format: 'd/m/Y h:m tt',
        value: new Date()
    });  
});

2

Answers


  1. Try This

    $(function () {
        $('#txtDateTimePicker').datetimepicker({
          format: 'd/m/Y h:i A',
          formatTime: 'h:i A',
          step: 15,  // Set the minute step to 15 minutes
          value: new Date()
        });
    });
    
    Login or Signup to reply.
  2. $(function(){
     $('.datetimepicker').datetimepicker({
      format :"DD/MM/YYYY h.m A",
     });
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search