Here in Brazil the date is shown in the format d / m / Y, but at the time of recording in mysql is needed the date in Y-m-d format.
How do I reverse that date at the time of recording the table?
How do I reverse that date at the time of recording the table?
Hi ev.garcia,
There are a couple of choices here. The simplest is to do a string conversion using this code in a Custom Code action:
You can also use the PHP strtotime() function *but* it recognises dates with / dividers as being US format mm/dd/yyyy. You'd need to show the date with - dividers to avoid this they are treated as dd-mm-yyyy. This will also not handle dates earlier than 1970, the start date of the UNIX Timestamp.
Bob
There are a couple of choices here. The simplest is to do a string conversion using this code in a Custom Code action:
<?php
$form->data['date'] = implode('-', array_reverse(explode('/', $form->data['date'])));
?>
You can also use the PHP strtotime() function *but* it recognises dates with / dividers as being US format mm/dd/yyyy. You'd need to show the date with - dividers to avoid this they are treated as dd-mm-yyyy. This will also not handle dates earlier than 1970, the start date of the UNIX Timestamp.
<?php
$form->data['date'] = date('Y-m-d', strtotime($form->data['date']));
?>
Bob
Bob,
First thanks for the feedback.
I did something wrong, because it did not work. What I did:
One. I put the php code before action DB save
2nd. Command Load JS
3rd. I showed in the Show Thanks Message and it appears correctly reversed

4th. But in Mysql date is not recorded.

5th. Does Mysql not understand this value to date?
6th. Previously when using the date in standard en-GB worked properly.

Thanks for your help.
First thanks for the feedback.
I did something wrong, because it did not work. What I did:
One. I put the php code before action DB save

2nd. Command Load JS

3rd. I showed in the Show Thanks Message and it appears correctly reversed

4th. But in Mysql date is not recorded.

5th. Does Mysql not understand this value to date?
6th. Previously when using the date in standard en-GB worked properly.

Thanks for your help.
Hi ev.garcia,
That's good thank you.
The code looks good but I'm not sure it will work in a Load JS action which is for JavaScript (though it accepts PHP too). Please add a Custom Code action and copy and paste the code into that. Hopefully then the code will execute at the correct point in the On Submit event.
Bob
That's good thank you.
The code looks good but I'm not sure it will work in a Load JS action which is for JavaScript (though it accepts PHP too). Please add a Custom Code action and copy and paste the code into that. Hopefully then the code will execute at the correct point in the On Submit event.
Bob
Hi,Bob
It worked perfectly.
Guess I'll have to pay you a beer. I enjoy this coin, it is very nice ...rsrsr
I'm really enjoying the ChronoForms. It is a great tool!!
I would like to understand how ChronoConnectivity fits with ChronoForms and in which situation I should use it.
I tried some tutorials, but only found the old version and I could not understand well .
Thank you once again.
It worked perfectly.
Guess I'll have to pay you a beer. I enjoy this coin, it is very nice ...rsrsr
I'm really enjoying the ChronoForms. It is a great tool!!
I would like to understand how ChronoConnectivity fits with ChronoForms and in which situation I should use it.
I tried some tutorials, but only found the old version and I could not understand well .
Thank you once again.
Hi ev.garcia,
The simplest way to think of ChronoConnectivity is that it is for showing lists of records while ChronoForms if for entering, editing or showing a single record*.
As an example. If you look at the FAQ listing page here there is a ChronoConnectivity listing in the main part of the page. The filter form is one part of a linked multi-page ChronoForm; the FAQ page itself is another page in the same form; and there is also an Edit view that you can't see.
Bob
* There's also quite a powerful lister in ChronoForms using the DB Multi Record Loader action. ChronoConnectivity has many more options though.
The simplest way to think of ChronoConnectivity is that it is for showing lists of records while ChronoForms if for entering, editing or showing a single record*.
As an example. If you look at the FAQ listing page here there is a ChronoConnectivity listing in the main part of the page. The filter form is one part of a linked multi-page ChronoForm; the FAQ page itself is another page in the same form; and there is also an Edit view that you can't see.
Bob
* There's also quite a powerful lister in ChronoForms using the DB Multi Record Loader action. ChronoConnectivity has many more options though.
This topic is locked and no more replies can be posted.