This topic is locked
[SOLVED]

 Format date-time field display in list

12/10/2018 11:33:00 PM
PHPRunner General questions
A
AlphaBase author

Basically I don't want to display seconds.
Current: 12/10/2018 5:48:48 PM
Proposed: 12/10/2018 - 5:48 PM
How would I do that?

A
AlphaBase author 12/11/2018

So the answer is:
I put this in the SQL query statement:
DATE_FORMAT(Start_Time, '%m/%d/%Y - %h:%i %p') AS Start_View,
Then I set the field in the list/grid as text.
The results are: 12/11/2018 - 09:49 AM
Perfect!

admin 12/11/2018

You can set 'View as' type of this field to Custom and use the following code:

$value = date("m\d\Y H:i", strtotime($value));


More info on formatting options:

http://us2.php.net/manual/en/function.date.php

A
AlphaBase author 12/11/2018

Ok, thanks. But that returns: 12dY 11:09
But I get your point.

A
AlphaBase author 12/11/2018

Using your solution as follows:
$value = date("m/d/Y - h:i A", strtotime($value));
Gives me the format I need, so I can get rid of the extra SQL fields. Of course, it raises the question: which is more efficient - the sql field(s) of or the PHP?

A
AlphaBase author 12/11/2018

I see the advantage of using your method. When adding a new record, when using the sql statement it doesn't immediately update the displayed value (without a refresh), whereas your method does.