This topic is locked

Time Picker

9/30/2025 10:36:24
PHPRunner General questions
A
Andreas Georgiou author

I am on PHPrunner 11.1 build 43757
I have a field that is varchar(50)
I wanted to capture the time. I use the Time field property and I have the Use time Picker.
No matter what i set the 12 hour or the 24 hour the time is saved as military time.
Any one has any suggestions on this please?

thank you,
Andrew

ChatGPT 9/30/2025

Hi Andrew,

In PHPRunner, when you set a field to use the "Time" field property, it typically saves the time in a standard format (often military time or 24-hour format) in the database. However, if you want to display the time in a different format (like 12-hour format) while still saving it in the database in its standard format, you can achieve this by adjusting the display settings.

Here are a few steps you can follow to handle this situation:

  1. Check Field Settings: Make sure that the field in question is indeed set to "Time" and that you've selected the "Use time Picker" option. The time format in the database will not change, but the way it is presented can be adjusted.


  2. Display Format: In PHPRunner, you can customize how data is displayed. Go to the "View" or "Edit" settings for the field in question and look for the "Format" option. You can set a custom format here. For displaying in 12-hour format, you might use a format string like h:i A (depending on how PHPRunner interprets format strings).


  3. Custom Code: If the built-in options are not sufficient, you can use custom code to format the output. In the "Events" section of PHPRunner, you can add code to format the time when it is displayed. For example:

    $value = strtotime($yourValue); // Assuming $yourValue contains the time
    $formattedTime = date('h:i A', $value); // Convert to 12-hour format

  4. Database Handling: If you're just displaying the time in a certain format but still want to maintain military time in the database, make sure that any data entry forms or scripts that handle this field are properly set up to accept time in the format you prefer.


  5. Testing: After making these changes, test to ensure that the time is saved correctly in the database and displayed in the desired format on the front end.



By following these steps, you should be able to display the time in 12-hour format while keeping the military time format in the database. If you continue to have issues, consider checking the PHPRunner documentation or reaching out to their support for more specific guidance related to your version.

Best of luck!

Andrew

A
Andreas Georgiou author 9/30/2025

did not work. Not matter what i do it saves it as a military time.
my time piker on the field if i set it to 12 hour or 24 they both saves it as military time in the database.

Any thing else to try?

thank you,
Andrew

C
Chris Whitehead 10/1/2025

As it's just a varchar which is storing the field, have you tried formatting the value in the before save event? This should save in the field as am/pm. then you might have to convert it back to 24hour format to display.

$values["my_time"] = date("g:i A", strtotime($values["my_time"]));

To convert back(not sure which event)
$time24 = date("H:i", strtotime($time12));

A
Andreas Georgiou author 10/6/2025

Hi @Chris Whitehead I have moved on that project.
The time is saved in the database coorrectly if it is set to milatary it will display as a military. If is set o non military the it would display as a non military.
the issue come when i take the value and send an email out from the background, the value is always a military time.

Thank you,
Andrew