Forums

Posting Custom Date to Created Date MySQL Field

mchmaster 15 Mar, 2009
Hi. I've looked around the forums for an answer to my problem but can't seem to find what I'm looking for, or maybe I just can't understand some of what's going on. Anyway, I'm using chronoforms 3.0 and I downloaded the submitcontent form, which is really helpful btw. It works great, but I want my users to be able to submit a date that is used instead of the created date. I'm using the calendar popup in my form and the onSubmit has this:

$_POST['created'] = date("Y-m-d H:i:s");

So my question is how do I get my date input (date_3) to be entered into the created date DB field instead of the current date. I've tried different things, but everything i've done has just given me a bunch of zeroes for dates. I appreciate any help. I know from looking at other postings that dealing with dates can get a little hairy.
Max_admin 16 Mar, 2009
Hi mchmaster,

whats the format of the date created using the calendar plugin ? try this code in the onsubmit:

$_POST['created'] = date("Y-m-d H:i:s", strtotime($_POST['date_3']));


let me know!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mchmaster 18 Mar, 2009
Thank you so much! That was exactly what I needed!
Max_admin 19 Mar, 2009
Great, please replace : $_POST['created'] by JRequest::getVar('created') and the same for the date field!

that's better for cleaning the posted data!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lemur 22 Apr, 2009

Great, please replace : $_POST['created'] by JRequest::getVar('created') and the same for the date field!
that's better for cleaning the posted data!
Cheers
Max



Hi, Max.

With $_POST it works.
But with JRequest::getVar('cb_myfield') I get:

Fatal error: Can't use function return value in write context in /var/www/vhosts/example.de/httpdocs/components/com_chronocontact/libraries/customcode.php(52) : eval()'d code on line 2


Is it really important to change to JRequest::getVar?

Thanks.

Leon
Max_admin 22 Apr, 2009
Hi Leon,

my typo, here you need to use:


JRequest::setVar('created', date("Y-m-d H:i:s", strtotime(JRequest::getVar('date_3'))));


Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lemur 23 Apr, 2009

... you need to use:


JRequest::setVar('created', date("Y-m-d H:i:s", strtotime(JRequest::getVar('date_3'))));


Cheers
Max



Yes. it works.

Thanks!
This topic is locked and no more replies can be posted.