I am sure this kind of question has been asked many times but I cannot find an answer that clarifies the issue. I use datepicker in the search dialog and would like to swap how it looks and the format of the date it displays depending on which country the use is in, but have the datepicker always return the selected date in the MySql format Y-m-d.
I have
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
$grid->setColProperty("FinishedAt", array("label"=>"Date", "width"=>50, "formatter"=>"date", "align"=>"right", "searchoptions"=>array("searchhidden"=>true, "sopt"=>array("bw")), "formatter"=>"date", "sorttype"=>"date", "formatoptions"=>array( "srcformat"=>'Y-m-d', "newformat"=>'jS/M/Y'))); $grid->setColProperty("TestAssignmentID", array("label"=>"TAID", "width"=>30, "hidden"=>true)); $grid->setColProperty("DepartmentID", array("label"=>"Department", "width"=>30, "hidden"=>true, "stype"=>"select", "searchoptions"=>array("searchhidden"=>true, "sopt"=>array("eq"), "value"=>"{$sDepartments}"))); $grid->setColProperty("CandidateListID", array("label"=>"Candidate List", "width"=>30, "hidden"=>true, "stype"=>"select", "searchoptions"=>array("searchhidden"=>true, "sopt"=>array("eq"), "value"=>"{$sCandidateList}"))); $grid->setColProperty("Assigned", array("label"=>"Assigned : Date", "width"=>30, "hidden"=>true, "stype"=>"select", "searchoptions"=>array("searchhidden"=>true, "sopt"=>array("eq"), "value"=>"{$sAssignedList}"))); $grid->setColProperty("UserID", array("label"=>"UserID", "width"=>30, "hidden"=>true)); $grid->setColProperty("OrganisationID", array("label"=>"OrgID", "width"=>30, "hidden"=>true)); $grid->setColProperty("Exported", array("label"=>"Exported", "width"=>30, "hidden"=>true)); $grid->setColProperty("StartedAt", array("label"=>"Active in last", "width"=>30, "hidden"=>true, "stype"=>"select", "searchoptions"=>array("searchhidden"=>true, "sopt"=>array("ge"), "value"=>"{$sActive}"))); $grid->setColProperty("activeBefore", array("label"=>"Active before", "width"=>30, "hidden"=>true, "searchoptions"=>array("searchhidden"=>true, "sopt"=>array("le")), "formatter"=>"date", "sorttype"=>"date", "formatoptions"=>array( "srcformat"=>'Y-m-d', "newformat"=>'d/M/Y'))); $grid->setColProperty("activeAfter", array("label"=>"Active after", "width"=>30, "hidden"=>true, "searchoptions"=>array("searchhidden"=>true, "sopt"=>array("ge")), "formatter"=>"date", "sorttype"=>"date", "formatoptions"=>array( "srcformat"=>'Y-m-d', "newformat"=>'d/m/Y'))); $grid->setColProperty("CreatedFromTemplateCandidateID", array("label"=>"Template", "width"=>30, "hidden"=>true, "stype"=>"select", "searchoptions"=>array("searchhidden"=>true, "sopt"=>array("eq"), "value"=>"{$sTemplates}"))); $grid->setColProperty("res", array("label"=>" ", "width"=>20, "sortable"=>false, "search"=>false, "classes"=>"sajqResults")); $grid->setColProperty("exp", array("label"=>"<img src='{$sIconExport}' onclick='exporttests();'>", "width"=>20, "sortable"=>false, "search"=>false)); // Set the datepicker. Note that the script automatically // converts the user date set in the jqGrid $grid->setDatepicker('activeBefore', array("showOn"=>"focus","altFormat"=>"Y-m-d"), true, true); $grid->setDatepicker('activeAfter', array("showOn"=>"focus","altFormat"=>"Y-m-d"), true, true); $grid->setDatepicker('FinishedAt', array("showOn"=>"focus","altFormat"=>"Y-m-d"), true, true); //$grid->datearray = array('CreatedAt'); // Finally set the database setting for the date $grid->setUserTime("H:i:s"); $grid->SetUserDate("d/m/Y"); $grid->setDbDate('Y-m-d'); $grid->setDbTime('H:i:s'); $grid->datearray = array('activeBefore','activeAfter','FinishedAt'); |
FinishedAt does come out correctly in jqgrid log, however I have to work with the output from
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Array ( [Action] => jqgridGetTestsTaken [iOrganisationID] => 33 [iCurrentUserID] => 44 [iTAID] => testtaken.TestTypeID = 1 and [oper] => grid [_search] => true [nd] => 1516895015532 [rows] => 25 [page] => 1 [sidx] => FinishedAt [sord] => desc [filters] => {"groupOp":"AND","rules":[{"field":"activeAfter","op":"ge","data":"17/01/2018"}]} [searchField] => [searchString] => [searchOper] => ) |
where as you can see the date format has not been changed to Y-m-d.
What am I missing?
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top