Remove Seconds from time

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
thecomputerchap
Veteran Member
Posts: 47
Joined: 2016-08-28 10:37

Remove Seconds from time

Post by thecomputerchap » 2016-08-28 10:44

Hi all,

I'm trying to achieve the above so that a time field will only display as 9:32AM as opposed to 9:32:46AM, thus removing the seconds and only showing the hours and minutes.

I've looked at modifying the dataFormats.cfg file but can't seem to locate the seconds variable. I guess %i is set to show both minutes and seconds.

I would also like to remove the seconds from the timer popup on the form.

Can anyone please point me in the right direction?

Cheers,

Dazzy.

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Remove Seconds from time

Post by grimblefritz » 2016-08-30 09:46

Here's the reference for mysql DATE_FORMAT():

http://dev.mysql.com/doc/refman/5.7/en/ ... ate-format

The definitions in dataFormat.cfg are used to format the data when it is written to the database. They don't control how it is displayed or formatted during input. When the data is read back and displayed, however, the effects of the SQL formatting will usually be observed. This is especially true for strings and numbers.

Of course, since AppGini feeds dates and times into picker functions, and those override the effects of the SQL formatting.

So, where you really want to be looking is at the tablename-tv.js and tablename-dv.js files. There, you can put jquery (or straight javascript) code to alter the behavior of the pickers. Such as only inputting hours and minutes. Or date with month and day, sans year.

(I rarely use the data formats, precisely because they only alter the data as it is written to the database. And for that, I prefer to add code to tablename_before_insert/update.)

pepemont
Posts: 2
Joined: 2015-06-05 17:06

Re: Remove Seconds from time

Post by pepemont » 2017-03-09 13:50

Quickfix : simply change from ".timepicker({ showSeconds: true," to ".timepicker({ showSeconds: false," in [database]_dml.php files ...
Regards

thecomputerchap
Veteran Member
Posts: 47
Joined: 2016-08-28 10:37

Re: Remove Seconds from time

Post by thecomputerchap » 2017-03-27 10:09

Thanks Pepemont - works a treat! :D

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Remove Seconds from time

Post by AhmedBR » 2022-07-29 00:34

Was looking for this, but found a better solution:

Add the following to dv function in the hook file!

Code: Select all

$html = str_replace('showSeconds: true', 'showSeconds: false', $html);
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Remove Seconds from time

Post by patsd102 » 2022-07-29 21:27

:)
23.17

Post Reply