DateTimePicker
DateTimePicker copied to clipboard
Date Format with Forward-Slashes
When you add a date format that contains forward slashes, which is a very common formatting in the United States for formatting dates, it breaks. I assume that the code is written only to handle hyphens (-) in dates, but this is super inconvenient. Any quick way to get this added in at least in our implementation? Not sure where to look.
I now see that you do have a construct option to change the separating character. I'm curious why you can't just format a timestamp without having to specify that. I also need to be able to set this on a per-input level using data- attributes. How would I go about adding the separator options as attributes on each node?
- You can achieve this using Locale-specific date separators
If you want
dateSeparator
to be locale-specific, you can setdateSeparator
,dateFormat
anddateTimeFormat
in locale files. For example, you want "/" as a date separator, so you can set it in "DateTimePicker-i18n-en-US.js" file as -
dateSeparator: "/",
dateFormat: "MM/dd/yyyy",
dateTimeFormat: "MM/dd/yyyy HH:mm"
But this will be global, the same date separator should be used for all fields.
- It is possible to add data attribute for separator settings. There are five separator fields -
dateSeparator
,timeSeparator
,timeMeridiemSeparator
,dateTimeSeparator
,monthYearSeparator
. Can you list fields for which data attribute should be added? Since there was no such requirement these data attributes were not added.
To fix this issue, I removed dateSeparator: "/"
from DateTimePicker.js and assigned it using below:
jQuery(document).ready(function(){
jQuery("#dtBox").DateTimePicker({
dateSeparator: "/", dateFormat: "MM-dd-yyyy"
});
});