date field=calculating time

More
11 years 6 months ago #42538 by discrockers
you mean like that?
<?php
// Modular item layout
// If customizing via CSS rules or JS scripts is not enough, then please copy the following file here to customize the HTML too
include(JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'tmpl_common'.DS.'item_layouts'.DS.'modular.php');


?>

<?php
$field_id = 18; // CHANGE THIS

if ( !empty($items->fieldvalues[$field_id]) )
{
$nowdate_secs = time();
$fielddate_secs = strtotime($items->fieldvalues[$field_id][0]);

$elapsed_secs = $nowdate_secs - $fielddate_secs;
echo $elapsed_secs / (60*60*24*365.25);
echo " years old <br/>";
}
?>

keep on rockin
J

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #42541 by ggppdk
Replied by ggppdk on topic date field=calculating time
Hello

$item not $items


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #42543 by discrockers
<?php
// Modular item layout
// If customizing via CSS rules or JS scripts is not enough, then please copy the following file here to customize the HTML too
include(JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'tmpl_common'.DS.'item_layouts'.DS.'modular.php');


?>

<?php
$field_id = 18; // CHANGE THIS

if ( !empty($item->fieldvalues[$field_id]) )
{
$nowdate_secs = time();
$fielddate_secs = strtotime($item->fieldvalues[$field_id][0]);

$elapsed_secs = $nowdate_secs - $fielddate_secs;
echo $elapsed_secs / (60*60*24*365.25);
echo " years old <br/>";
}
?>

Still the same, no errors no "age"...do I have to edit anything in the fieldsettings?

keep on rockin
J

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #42546 by ggppdk
Replied by ggppdk on topic date field=calculating time
Hello

set error_reporting parameter to "simple"
in
Joomla Global configuration / Server Tab

then use the code without the if statement:
Code:
<?php $field_id = 18; // CHANGE THIS $nowdate_secs = time(); $fielddate_secs = strtotime($item->fieldvalues[$field_id][0]); $elapsed_secs = $nowdate_secs - $fielddate_secs; echo $elapsed_secs / (60*60*24*365.25); echo " years old <br/>"; ?>


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #42549 by discrockers
aaahhhh...we are getting closer! :)

looks like the time is displayed below the whole template instead of repalcing the date/ Birthday

keep on rockin
J
Attachments:

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #42551 by discrockers
the second line is because I also insert the code in the html5-item.php. I delete the code and now the is only one time/line displayed

keep on rockin
J

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.456 seconds
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save