While selecting time in DateTime picker component, I want to change the format of the time in clock to 24 hrs instead of 12 hrs.

Hi Team,

Good Day,

FYI, I am using Angular7.

please Find the below code snippets that I am trying to check

<ejs-datetimepicker id='endDateTime' name="endDateTime" formControlName="endDateTime" format ='yyyy-MM-dd HH:mm:ss PT' placeholder='End Date'
[min]='minEnd' [max]='maxEnd' (change)="changeEndDate($event)" class="dateTimePicker" timeFormat='HH:mm' [showTodayButton]="false" step="5">
ejs-datetimepicker>

Image_6440_1691590587756

Could You please help me


Thanks & Regards,

Pavan Atmakuri.


1 Reply

PK Priyanka Karthikeyan Syncfusion Team August 10, 2023 01:10 PM UTC

Hi Pavan Kumar,

If you need to change the format to 24 hours format while selecting a time, you can achieve this by using the change event as follows.

<ejs-datetimepicker
     ....
     (change)="onchange($event)"
 >
 </ejs-datetimepicker>
onchange(eventany) {
    this.datetime.format = 'dd-MMM-yy HH:mm:ss';
    this.datetime.timeFormat = 'HH:mm:ss';
}


Sample: https://stackblitz.com/edit/angular-chxprx-dduf6k?file=src%2Fapp.component.ts,src%2Fapp.component.html

API Reference: https://ej2.syncfusion.com/angular/documentation/api/datetimepicker/#timeformat

https://ej2.syncfusion.com/angular/documentation/api/datetimepicker/#format

https://ej2.syncfusion.com/angular/documentation/api/datetimepicker/#change

If this does not meet your requirement, please let us know. We are happy to assist you further.

Regards,

Priyanka K


Loader.
Up arrow icon