Testing date format options on all major 4 browsers (Safari, Chrome, IE & Firefox) while working on windows works well.
However, when testing it on MAC machines, the format option failed within Safari (Firefox on MAC works well).
My format option is:
gridField.formatter = 'date';
gridField.formatoptions = {};
gridField.formatoptions['srcformat'] = 'U/1000';
gridField.formatoptions['newformat'] = 'm/d/Y H:i:s';
Which in Safari (on a MAC only) will yield: NaN/NaN/NaN NaN:Nan:NaN.
Any idea how to overcome the problem?
Thanks,
The problem is the following. Free jqGrid uses mostly the same code of
$.jgrid.parseDate
function like jqGrid 4.7. It support the usage"u"
and"U"
in the date format in two different cases. The first case is the usage of"u"
and"U"
without any additional format specification (for example,srcformat:"u"
). It means that jqGrid usesnew Date(inputValue*1000)
to parse the input value. The input value like1418297439
will be displayed as12/11/2014 11:30:39
usingnewformat: "m/d/Y H:i:s"
. On the other side you have1418297439000
instead of1418297439
in the input data and jqGrid don't have some exact formatter for the case.You use format
srcformat: "U/1000"
in your original demo http://jsfiddle.net/OlegKi/ngm5rhgp/7/. Such format ("U/1000"
) don't exist at all. The format"U/1000"
will be interpretet in the same way like"U/"
,"U."
,"U/BlaBla"
,"U:H:i:s"
or any other which start withu
following with separator. Because the input data looks like1418297439000
and have no additional separators (,
,/
,,
,
and some other) then only the first formatterU
will be used, but it will be interpreted now asu
formatter, which means millisecond. Theu
format will be used typically for the format like12/11/2014 11:30:39,123
where tha last123
part is the millisecond part of the time.It seems that Safari on MAC don't allow to create the date as
new Date(1970, 1, 1, 0, 0, 1418297439000)
which uses jqGrid with1418297439000
as input data andsrcformat: "U/1000"
.What I suggest you to do is modifying the input data and the usage of
srcformat: "u"
format. One need to enumerate all items of input data and to devidestart_time
andend_time
properties to100
. I used in my demo http://jsfiddle.net/OlegKi/ngm5rhgp/8/ the codeand have replaces
srcformat: "U/1000"
tosrcformat: "u"
. If you have not"local"
value ofdatatype
than you can modify the data inside ofbeforeProcessing
callback.UPDATED: To simplify processing of the time in milliseconds since the Unix Epoch (January 1 1970 00:00:00 GMT), like
1418297439000
, I introduced in free jqGrid new format option:srcformat: "u1000"
. The new demo http://jsfiddle.net/OlegKi/ngm5rhgp/9/ uses unmodified input data and just usesrcformat: "u1000"
instead ofsrcformat: "U/1000"
. To use it one have to use the latest free jqGrid from GitHub.