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

da darrenhallinan 19 Oct, 2011
Hi all quick question

using CC I am looking for a way to display the recordtime column in the format DD/MM/YY

I found the code below which will display the MM/DD/YYYY format

<?php
$date=explode(' ',$MyRow->recordtime);
echo $date[("0")];
?>


I have played with it to try and get it the way i need it but no joy.

anyone know how I can do this?
Gr GreyHead 19 Oct, 2011
Hi darrenhallinan ,

Please try
<?php
$date = strtotime($MyRow->recordtime);
$date = date('m/d/Y', $date);
?>
. . . 
<?php echo $date; ?>


Bob
da darrenhallinan 19 Oct, 2011

<?php
$date = strtotime($MyRow->recordtime);
$date = date('m/d/Y', $date);
?>
. . . 
<?php echo $date; ?>



Tried that Bob

The result is that each date shows as 01/01/1970

close but no cigar!
Gr GreyHead 19 Oct, 2011
Hi darrenhallinan,

Please add some intermediate echo statements to see what the value is at each step. It could be that $myRow->recordtime is empty, or I've got the syntax wrong . . .

Bob
La Laus 08 Dec, 2011
I think the syntax may be wrong, I have same issue and I too get 01/01/1970

Have checked recordtime and it is not empty.

This is what I have in the Body:

<?php
$date = strtotime($MyRow->recordtime);
$date = date('d/m/Y', $date);
?>
<tr><td class="table_norm" align="center">{stu_surname}</td><td class="table_norm">{stu_firstname}</td><td class="table_norm">{userscode}</td><td class="table_norm">{role}</td>
<td class="table_norm">
<?php echo $date; ?></td>
<td class="table_norm">{schoolcode}</td><td class="table_norm" align="center"><a href='index.php?option=com_chronocontact&chronoformname=FA001_records&id={cf_id}'>View</a></td><td class="table_norm">{edit_record}</td><td class="table_norm">{delete_record}</td></tr>
ar armandojaleo 11 Dec, 2011

I think the syntax may be wrong, I have same issue and I too get 01/01/1970

Have checked recordtime and it is not empty.

This is what I have in the Body:

<?php
$date = strtotime($MyRow->recordtime);
$date = date('d/m/Y', $date);
?>
<tr><td class="table_norm" align="center">{stu_surname}</td><td class="table_norm">{stu_firstname}</td><td class="table_norm">{userscode}</td><td class="table_norm">{role}</td>
<td class="table_norm">
<?php echo $date; ?></td>
<td class="table_norm">{schoolcode}</td><td class="table_norm" align="center"><a href='index.php?option=com_chronocontact&chronoformname=FA001_records&id={cf_id}'>View</a></td><td class="table_norm">{edit_record}</td><td class="table_norm">{delete_record}</td></tr>



Hello to all!

The solution is...


<?php
	$date = DateTime::createFromFormat('Y-m-d - H:i:s', $dataItem->recordtime);
	echo $date->format('l, d \d\e F \d\e Y');
?>


For more information visit: http://www.php.net/manual/en/datetime.createfromformat.php

Greetings😀 !
La Laus 12 Dec, 2011
Armando,

Thanks for your suggestion.

When I input your code I am given the following error:

Fatal error: Call to undefined method DateTime::createFromFormat() in (root removed by me)/components/com_chronoconnectivity/libraries/connection.php(303) : eval()'d code on line 2
Gr GreyHead 12 Dec, 2011
Hi Laus,

Please check the PHP manual reference; the function that Armando has used is only available from PHP 5.3.0

Bob
La Laus 12 Dec, 2011
Ah, that explains it, I am using 5.2.17
This topic is locked and no more replies can be posted.