Forums

Help with date and time table output

Tgoodrich 16 Apr, 2014
Hi,

I am using chronoforms and chronoconnectivity together.

I have a form that when filled out and submitted it populates a database table which is shown in the front end of my website using chronoconnectivity. The table was created in chronoforms and one of the options when making the table was to have a field named "created" with the type "DATETIME" which outputs as 0000-00-00 00:00:00. I like this because it gives the current date and time of when the form was submitted automatically. The problem is I need to change the format.

How can I get the current date and time the form was submitted automatically but in this format eg.. 1/1/2014 12:00:00 AM

Thanks
Max_admin 16 Apr, 2014
Answer
1 Likes
Hi Tgoodrich,

That's the default date format in mysql, you should dhange the format when you display it, so go to the "PHP functions" box in your connection and use this:

Model.field:return date("d/m/Y H:i:s", strtotime($cell));


I will move this topic to connectivity forum🙂

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Tgoodrich 17 Apr, 2014
1 Likes
Hi Max,

Thanks, works perfect!

I took your code:
Model.field:return date("d/m/Y H:i:s", strtotime($cell));


and changed it to:
Model.field:return date("m/d/Y g:i:s a", strtotime($cell));


For anyone else interested in this, just use Max's code as he stated above. Just make sure to change "Model.field" to your Model name and field name.

If you would like to format your date and time to appear differently than what is noted above, visit
http://php.net/manual/en/function.date.php to get a list of characters that can be used for your formating needs.
This topic is locked and no more replies can be posted.