This topic is locked
[SOLVED]

 Format time without seconds

9/8/2010 10:37:08 PM
PHPRunner General questions
P
procheck author

I'm trying to create a datetime field that would not display the seconds.

I've tried this - date("m/d/y g:i A") in the default value box in the Edit As date

which works in the edit field only but not in the datetime picker or on the List page.

Both of these still show the seconds. Is there a way to do this?
Thanks
Al

A
ann 9/9/2010

Al,
use this code on the Custom format tab in the View as settings dialog.

P
procheck author 9/10/2010

Hi Ann,
This worked but then I discovered that in order to allow the time to be set, I needed to separate the date and time to separate fields. To format the time, in the Custom format tab I added this code.
$value = $data["StartTime"];

$value = date("g:i A",strtotime($value));
This appears to work ok. In the "Edit As" for Time I validate as Time and the default is date("g:i A"); . This works also. I did not select Display Seconds. When I go into edit mode the current time is displayed in the field. I select a new time and it gets displayed in the edit field. I save the field and the current date gets displayed again. This would be confusing to a user. In the edit window, I click on "Back to list" the new correct date is displayed in the List. In the inline edit the same thing happens and I must reload the page to display the correct date.
I added this setTimeout('window.location.reload(true)',500); to include\inlineedit.js but this only fixes Inline edit and not the regular edit screen. It also gets overwritten every time I Rebuild my project which is often.
Hopefully I've been clear enough.
Al

Admin 9/10/2010

Make sure you are applying Default value on the Edit page as well. It looks like this option is turned on.

P
procheck author 9/10/2010

I did have it set.

Admin 9/10/2010

That was meant to say 'Make sure you are NOT applying it on Edit page as well'.
As far as I understand you saying that default value is applied on the Edit page as well and you don't need it.

P
procheck author 9/10/2010

I removed the checkmark for "Apply it on Edit page as well" and this corrected the problem.

Thanks once again. It's amazing how many problems you & your staff are able to solve.

I know it can sometimes be a thankless job.
Hopefully new potential customers will find this forum and see many happy customers!

Feel free to use any of my comments in your advertising.
Al