Topic: Datetimepicker format value for Django invalid
The format of the datetimepicker does not match the format expected by django, django expects a datetime format '2023-10-31T16:20' ISO 8601 format and mdb datetimepicker sends '2023-10-31, 16:20'.
How can I format the datetime so that I receive it in Django with the correct format '2023-10-31T16:20' ?
const pickerTimeOptions = document.querySelector('#datetimepicker-timeOptions');
new mdb.Datetimepicker(pickerTimeOptions, {
timepicker: { format24: true },
datepicker: { format: 'dd-mm-yyyy'},
});
Kamila Pieńkowska staff answered a year ago
What do you mean by Django expects a datetime format '2023-10-31T16:20' ISO 8601
?
Are you talking about the format of the input that is in the datetimepicker?
Arthur pro premium priority commented a year ago
No, I'm talking about the value that is returned in the django view. My concern is that in django, as soon as you pass through the request.POST, the data is immutable. I'd like to know if there's a way to format the date in the JS MDB function.
Kamila Pieńkowska staff commented a year ago
You can manipulate the value format in your views.py
.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 6.4.2
- Device: pc
- Browser: Firefox
- OS: w11
- Provided sample code: No
- Provided link: No