This topic is locked
[SOLVED]

 I' am having problem when editing records with time AM/PM.

1/12/2016 10:18:16 AM
PHPRunner General questions
P
pmorenoc07 author

Hello,
I' am having problem when editing records with time AM/PM.
here is may setting:
database

Field name: start_time and end_time

Field Type: time
MySQL store time in 24h 13:00:00, so I using

$value= date("h:i A",strtotime($value));

to convert to to 01:00 PM.
Here is the problem, when I try to edit the time that is PM (01:00 PM) the system change it to 01:00 AM, and it save it like 01:00:00 instead of13:00:00.
I have done several test changing the time field to text field but it keep doing the same.
How can I force the system to convert 12 Hour format to 24 Hour format before updating the record??
Thank you.

D
DealerModulesDevClub member 1/12/2016

Try using

$value= date("G:i", strtotime($value));


Paul



Hello,
I' am having problem when editing records with time AM/PM.
here is may setting:
database

Field name: start_time and end_time

Field Type: time
MySQL store time in 24h 13:00:00, so I using

$value= date("h:i A",strtotime($value));

to convert to to 01:00 PM.
Here is the problem, when I try to edit the time that is PM (01:00 PM) the system change it to 01:00 AM, and it save it like 01:00:00 instead of13:00:00.
I have done several test changing the time field to text field but it keep doing the same.
How can I force the system to convert 12 Hour format to 24 Hour format before updating the record??
Thank you.

Sergey Kornilov admin 1/13/2016

In your events like BeforeAdd/BeforeEdit you can use something like this:

$values["TimeField"] = date("H:i", strtotime($values["TimeField"]));
P
pmorenoc07 author 1/13/2016



In your events like BeforeAdd/BeforeEdit you can use something like this:

$values["TimeField"] = date("H:i", strtotime($values["TimeField"]));



Thank you all, that works.