Greetings,
I have the premium paid version of this excellent phpgrid.
I have several database fields that are 'time' only, not datetime.
I need to be able to integrate the timepicker with these fields. I tried something like this:
$col["formatter"] = "time";
$col["formatoptions"] = array("srcformat"=>'H:i:s',"newformat"=>'H:i:s A',"opts" => array("timeOnly" => true, "timeFormat"=>"hh:mm tt"));
But the timepicker does not show and the fields are not editable.
How can I go about making 'time' fields work with the timepicker?
Thank you.
Thank you.
Here you go: demos/integration/timepicker.php
# to make it date time
$col["formatter"] = "datetime";
# opts array can have these options: http://trentrichardson.com/examples/timepicker/#tp-options
$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'H:i:s A',"opts" => array("timeOnly" => true, "timeFormat"=>"hh:mm:ss tt"));
Following demo show working example of how to use timepicker:
demos/integration/timepicker.php
You can find and run it in your demo app and downloaded package.
Let me know for any further help.
I put that code, and can see the timepicker, but when I update the fields i always get 00:00:00 (but they are OK on database)
What field type should I use in the database???
Try this:
$col["formatoptions"] = array("srcformat"=>'H:i:s',"newformat"=>'H:i:s',"opts" => array("timeOnly" => true));
The newformat does not have AM/PM option and it's 24hour time selection.
how do i display time as 12 hour time slection.
displays as:
07/14/2015 13:41:33PM
need to display as:
07/14/2015 01:41:33PM
my code:
col["formatter"] = "datetime";
$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'m/d/Y H:i:s A',"opts" => array("timeOnly" => FALSE, "timeFormat"=>"hh:mm:ss tt"));
You can set:
$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'M d Y h:i A',"opts" => array( ));
newformat: small h, and A will show 12 hour with AM/PM option
I had the same issue and the snippet below fixed everything for me EXCEPT how do I not display the seconds? We only want to input and display hours:minutes. Like 23:34 or 09:15
$col["formatoptions"] = array("srcformat"=>'H:i:s',"newformat"=>'H:i:s',"opts" => array("timeOnly" => true));