Forums

How to edit (update) a date input (element)

bilal.abdeen 02 Apr, 2016
Bob,

I am trying to read a date input element, update it, and then save it back.

For reading the date value, I had to change the date format, before displaying it (see below.)
$form->data[date_of_birth] = date( "d/m/Y", strtotime($form->data[date_of_birth]) ) ;

I am still struggling to find a way to save this date back to the database. What is saved back into the database is (0000-00-00 00:00:00).

Debugging:
Array
(
    [chronoform] => RegFormEdit
    [event] => submit
    [firstname] => Bilal
    [lastname] => Abdeen
.....
    [marital_status] => Single
    [date_of_birth] => 04/11/2010  // The date I entered was actually 11/04/2010. Why were the day and month reversed? 
)
.....
Array
(
....
           [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => UPDATE `iwwaj_jsn_users` AS `SAVEjsnUser` SET `firstname` = 'Bilal', `lastname` = 'Abdeen', 
... 
`date_of_birth` = '11/04/2010' // This is the date I entered. 
.....;
                        )
                )
.....
)
I tried the following before submission, but it did not help.
$form->data[date_of_birth] = date ("d/m/Y", strtotime($form->data[date_of_birth]) );

By the way, storing dates when creating a new database record (registration of a new user) works very smoothly. However, I am not sure what is wrong with updating dates.

Thank you for your effort and time to help...
GreyHead 04 Apr, 2016
Hi bilal.abdeen,

What format do you have set in the Datepicker box element? It looks as though d/m/y and m/d/y are getting mixed up somewhere.

Bob
bilal.abdeen 04 Apr, 2016
Bob,

Yes, I share your suspicious, I think there is something wrong with handling the date field by the form code. However, I don't think it is in how it is defined. Please. see the attached screen shot.

Anyway, I have given up fixing this. Since I really don't need to update the editing form, I will just use the standard EasyProfile editing form. Thank you for your help, anyway.
This topic is locked and no more replies can be posted.