In the "Front List Settings" - "Custom Listing Settings" section, I have the following in the body section:
Both mbrshp_date and expires are dates in this format: YYYY-MM-DD. I would like them in this format: Jun 14, 2012.
I have tried several php codes such as:
but they aren't working here. I think I'm not understanding the correlation with the mysql table. Can I even use php code here and if so, what should work here?
Thanks.
<table class="gridtable">
<tr>
<td width=80>{first_name}</td>
<td width=80>{last_name}</td>
<td width=300>{family}</td>
<td width=180>{item_name}</td>
<td width=100>{mbrshp_date}</td>
<td width=100>{expires}</td>
</tr>
</table>
Both mbrshp_date and expires are dates in this format: YYYY-MM-DD. I would like them in this format: Jun 14, 2012.
I have tried several php codes such as:
<td width=100>
<?php
$date = date('M d, Y', {mbrshp_date});</td>
echo $date;
?>
but they aren't working here. I think I'm not understanding the correlation with the mysql table. Can I even use php code here and if so, what should work here?
Thanks.
Hi Chriso0258,
You can't usually mix curly brackets and PHP but I think that you can use PHP. The data will be in $row['column_name'] in the latest release so something like
Bob
Updates from Max's post after this one.
You can't usually mix curly brackets and PHP but I think that you can use PHP. The data will be in $row['column_name'] in the latest release so something like
<?php
$expires = strtotime($row['expires']);
$expires = date('d-m-Y', $expires);
?>
. . .
<td width='100' ><?php echo $expires; ?></td>
should to the trick (with the correct data format string).Bob
Updates from Max's post after this one.
Hi,
Just a small fix, its:
:)
Regards,
Max
Just a small fix, its:
$row['column_name']
but not $row->column_name
:)
Regards,
Max
Hi, I have a similar problem. I am using the following code in my form to poplulate a dropdown list with course availability:
The output is:
etc...
I would like to change my code so that the output is:
Basically I would like to extract the full textual representation of a month from date(). I've tried using
<?php
if (!$mainframe->isSite() ) {return;}
$db =& JFactory::getDBO();
$query = "
SELECT `id`, `location`, `date`, `places_available`, `rel`
FROM `#__training_courses`
WHERE `course_name` = '2 Day Refresher Training'
ORDER BY `course_name`;
";
$db->setQuery($query);
$options = $db->loadAssocList();
foreach ( $options as $o ) {
echo "<option id='".$o[id]."' value='".$o[date]." - ".$o[location]."' rel='".$o[rel]."'>".$o[location]." - ".$o[date]." - Places available: ".$o[places_available]."</option>";
}
?>
The output is:
Dubai - 2012-7-27 - Places available: 13
Edinburgh - 2012-3-12 - Places available: 23
etc...
I would like to change my code so that the output is:
Edinburgh, March 9 - Places available: 23
Basically I would like to extract the full textual representation of a month from date(). I've tried using
.$o[date("F")]
but it didn't work!
Hi quantum_leap,
Try
Bob
Try
foreach ( $options as $o ) {
$date = date('F', $o['date']);
echo "<option id='{$o['id']}' value='{$date} - {$o['location']}' rel='{$o['rel']}'>{$o['location']} - {$date} - Places available: {$o['places_available']}</option>";
}
Bob
Unfortunately this always outputs January(even when January was not the month of the date).
Nailed it!
Cheers for the pointers though!
$date = date('F', $o['date']);
needs to be$date = date('F', strtotime($o['date']));
.Cheers for the pointers though!
Hi quantum_leap,
Well done, that's right, you need a timestamp for the date() function not a date-time string.
Bob
Well done, that's right, you need a timestamp for the date() function not a date-time string.
Bob
Question about this...my date is also my edit field. If I change {mydate} to <?php echo $row['mydate']; ?> so that I can customize the output, how will the edit link work?
Hi megana,
I suspect that it will work OK - but I'm not certain. Keep a backup and test.
Bob
I suspect that it will work OK - but I'm not certain. Keep a backup and test.
Bob
Hi megana,
Where are you using this and what code do you have at present?
Bob
Where are you using this and what code do you have at present?
Bob
Hi Bob,
In the "Front List Settings" - "Custom Listing Settings" section:
In the "Front List Settings" - "Custom Listing Settings" section:
<td class="in-month">{checkbox} <?php echo date("N",strtotime($row['lunchdate'])); ?></td>
This topic is locked and no more replies can be posted.