The AppGini Blog
A few tips and tricks to make your coding life a tiny bit better.

How to hide the seconds in a time field

If you have a time field in your AppGini application, it displays a time picker in the detail view like this one:

Default timepicker field, with seconds displayed

The timepicker includes seconds. If you wish to hide the seconds part, you could do so by editing the tablename_dv hook. Open the generated hooks/tablename_dv.php file in a text editor (where tablename is the name of the concerned table) and look for the dv function, then add this line inside it:

1
$html = str_replace('showSeconds: true', 'showSeconds: false', $html);

If you refresh the page, the time field would now look like this, showing no seconds:

Updated timepicker without seconds

The method described above works only for time fields. For datetime fields, try adding the following code to the file hooks/tablename-dv.js (where tablename is the name of the concerned table β€” create that file if it’s not already there):

1
2
3
4
5
6
7
$j(function() {
  $j('#datetimefield').parents('.input-group')
    .datetimepicker(
      'format', 
      AppGini.datetimeFormat('dt').replace(/:ss/, '')
    );
});

Replace datetimefield in the above code with the actual datetime field name.