How I can split {recordtime} in CC to date and time?
I already tried:
But it doesn´t work. As a result I get 'recortime}'
I already tried:
<?php
$d='{recordtime}';
$datum = left($d,10);
?>
<td width="70 px"><?php echo $datum; ?></td>
But it doesn´t work. As a result I get 'recortime}'
Hi navajofra,
I think that you need to use the $MyRow data object to use the data in PHP. Here's a code snippet that I wrote to re-format dates in the CC Body section. In your case you need to add the left() line to select the date part of the date-time string:
Bob
I think that you need to use the $MyRow data object to use the data in PHP. Here's a code snippet that I wrote to re-format dates in the CC Body section. In your case you need to add the left() line to select the date part of the date-time string:
// reset dates to m/d/Y format
$dates = array( 'first_date', 'second_date');
foreach ( $dates as $v ) {
$k = $v.'_mdy';
$MyRow->$k = '';
$date = $MyRow->$v;
if ( $date ) {
$date = explode('-', $date);
$date = $date[1].'/'.$date[2].'/'.$date[0];
$MyRow->$k = $date;
}
}
?>
. . .
<td><?php echo $MyRow->first_date_mdy; ?></td>
Bob
I tried the suggested code. However I think it doesn´t fit exactly my needs.
What i like to show in the CC form is only the date of each record:
I put to Connection view settings of the body field:
<tr>
<td width="70 px">{recordtime}</td>
</tr>
As a result i get: 2010-04-03 - 18:12:28
But i want to show only 2010-04-03
what is the coding for showing it?
I think there doesn´t need to be a "foreach", because CC already fetched the actual record from the table.
What i like to show in the CC form is only the date of each record:
I put to Connection view settings of the body field:
<tr>
<td width="70 px">{recordtime}</td>
</tr>
As a result i get: 2010-04-03 - 18:12:28
But i want to show only 2010-04-03
what is the coding for showing it?
I think there doesn´t need to be a "foreach", because CC already fetched the actual record from the table.
Hi navajofra,
No it doesn't exactly fit your needs but you can easily adapt it to do what you need. All the necessary code is there.
Bob
No it doesn't exactly fit your needs but you can easily adapt it to do what you need. All the necessary code is there.
Bob
Hallo GreyHead,
I understand the coding now. But how can I get the content of the field recordtime?
with $date='{recordtime}' it works, but I cannot explode $date. The result of the date[0] is always the content of {recordtime}. date[1] and date[2] are empty.
How can I ask for the actual content of the field recordtime using php code in Connection View Settings-Body?
I understand the coding now. But how can I get the content of the field recordtime?
with $date='{recordtime}' it works, but I cannot explode $date. The result of the date[0] is always the content of {recordtime}. date[1] and date[2] are empty.
How can I ask for the actual content of the field recordtime using php code in Connection View Settings-Body?
Hi navajofra,
You probably don't need to explode recordtime, just take out the substring. A MySQL date-time field value is usually in the form YYYY-MM-DD HH:MM:SS but for some reason ChronoForms uses YYYY-MM-DD - HH:MM:SS
Look in the database record to see what form at your fields take.
Bob
You probably don't need to explode recordtime, just take out the substring. A MySQL date-time field value is usually in the form YYYY-MM-DD HH:MM:SS but for some reason ChronoForms uses YYYY-MM-DD - HH:MM:SS
Look in the database record to see what form at your fields take.
Bob
My problem is only how to get out the date from the recordtime field of the current record if I use the body of Connection View Settings.
I assume chronoconnectivity has already stored the current record to an array as $row->recordtime or something else.
I don´t know the name of the array so that I could use it instead of {recordtime} in the Connection view settings.
I know the Connection view settings body is only a template for displaying the records.
Can I put the code into the body or where else?
I assume chronoconnectivity has already stored the current record to an array as $row->recordtime or something else.
I don´t know the name of the array so that I could use it instead of {recordtime} in the Connection view settings.
I know the Connection view settings body is only a template for displaying the records.
Can I put the code into the body or where else?
Hi navajofra,
I expect that it is stored as a string - look at the database table with PHPMyAdmin or EasySQL or the ChronoForms DataViewer to check.
You can run PHP inside the CC Body box (but not MySQL queries).
Bob
I expect that it is stored as a string - look at the database table with PHPMyAdmin or EasySQL or the ChronoForms DataViewer to check.
You can run PHP inside the CC Body box (but not MySQL queries).
Bob
Yes it is saved as a string. what shall I do?
Btw i can run MYSQL queries in the CC Body box.
But only the first record of a table gets displayed. I don´t know the reason.
Maybe it is my coding.
<?php
$database->setQuery( "SELECT * FROM #__chronoforms_profile WHERE cf_id = cf_id LIMIT 1" );
$categories = $database->loadObjectList();
foreach($categories as $category) {
$date=explode(" ",$category->recordtime);
echo '<td width="80 px">'.$date[0]."</td>";
}
?>
Btw i can run MYSQL queries in the CC Body box.
But only the first record of a table gets displayed. I don´t know the reason.
Maybe it is my coding.
<?php
$database->setQuery( "SELECT * FROM #__chronoforms_profile WHERE cf_id = cf_id LIMIT 1" );
$categories = $database->loadObjectList();
foreach($categories as $category) {
$date=explode(" ",$category->recordtime);
echo '<td width="80 px">'.$date[0]."</td>";
}
?>
This topic is locked and no more replies can be posted.