datetimepicker
datetimepicker copied to clipboard
Datetimepicker does not support the standard date/time format (ISO-8601)
Unless there's a feature I am missing, DateTimePicker doesn't support the international standard date/time format ISO-8601, e.g. 1981-01-28T00:00:00
(see http://xkcd.com/1179/ and http://en.wikipedia.org/wiki/ISO_8601 ) Unfortunately this makes it difficult to use when populating with JSON or any other data source that uses the standard format.
Tried:
format: 'Y-m-dTH:i:s'
format: 'Y-m-d\TH:i:s'
(Puts the time zone in place of the T)
format: 'Y-m-d"T"H:i:s'
(Puts the time zone and quotes in place of the T, e.g. 2014-12-13"MST"10:26:00
)
format: 'c'
--> From the ISO-8601 option in the PHP date format documentation which is for some reason is linked on the datetimepicker website as the official format documentation (Returns "c")
+1 on this. For example Angular.js uses ISO8601 everywhere and this is only format for datetime inputs. See https://docs.angularjs.org/api/ng/input/input%5Bdatetime-local%5D for example.
Currently receipt «How to use moment.js with jquery datetimepicker» from docs along with according format settings seems to solve problem for me:
Date.parseDate = function( input, format ){
return moment(input,format).toDate();
};
Date.prototype.dateFormat = function( format ){
return moment(this).format(format);
};
element.datetimepicker({
format: 'YYYY-MM-DDTHH:mm:ssZ',
formatTime: 'HH:mm',
formatDate: 'YYYY-MM-DD',
})
But I'm afraid can redefining of Date
methods break something or not.
You have to double-escape the T (because the format string uses \T
, and the backslash itself needs escaping to be embedded in JavaScript. That is, use format: 'Y-m-d\\TH:i:s'
.
Hello!
Is it possible to show date-time in format Y-m-d H:i
, but convert to/form value as Y-m-d\\TH:i:s
?
So, seeing this issue, can one not submit ISO8601?
I need to show a human-readable format in the input but submit in 8601. Is this not possible?
double escaping does not work, when I use Y-m-d\\TH:i:s
I simply get 2016-02-17\PST00:00:00
. Seems like an odd oversight not having an ISO8601 compatible format.
Y-m-d\\TH:m:s
is working fine for me... It renders the correct result: 2016-02-07T22:02:06
@HasPhillip May be you resolved problem already, but anyway it can be helpful for someone. I had the same problem on version 2.4.7, went back on version 2.4.5 - and double escaping works.
Hey everybody. It was hard, it was about 1 hour, but i have fount the solution. All what you need just add validateOnBlur:false