Forums

How to show cf_created in DD/MM/YYYY Format?

darrenhallinan 02 Dec, 2011
Ok so I had this issue before with CC which I never got resolved, I was not to worried as the project I was working on was only used for myself.


But im now building a database which the end user will want to be able to search and sort by date so I need the data to be stored in yyyy:mm:dd format but would need to be able to display it to the user in the format dd/mm/yyyy

I have tried and tried many ways I found but they dint seem to work (white page of death) or just display the default 01/01/1970

Bob asked me to try:
 <?php
$date = strtotime($MyRow->recordtime);
$date = date('m/d/Y', $date);
?>
. . .
<?php echo $date; ?>

In CC but it didnt work, and I think it would have changed with C4

i tried
echo date('Y m d',strtotime($cf_created));


which also does not work.

Do i need to add a statement in the MYSQL box or what do i need to do?
darrenhallinan 02 Dec, 2011
I might also add

Im using joomla 1.7
MYSQL 5 & PHP 5
GreyHead 02 Dec, 2011
Hi Darren,

I would probably change the column type of the recordtime column to DATETIME. The format that ChronoForms uses has an extra - but MySQL seems happy to ignore that.

The strtotime() function should work but note that if the data string uses '/' separators then it's assumed to be m/d/y - if it uses '-' separators it's assumed to be d-m-y.

Add temporary echo statements to your code to see what is being found at each step.

A white screen is usually a sign of a PHP error that is not being displayed. To debug set the Site Error Reporting temporarily to Maximum and hopefully you'll get a more useful error message.

Bob
Max_admin 09 Dec, 2011
Hi Darren,

Did you try:

echo date('Y m d',strtotime($form->data['cf_created']));


?? I think this should work.

Are you sure that you are accessing the datetime value correctly ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.