Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • splico123 Friend
    #162715

    there are number of people on forum wondering how to do this and there are few outdated sollutions, for J1.6 here is what you have to do:

    open file under plugins/system/jat3/core/common.php

    change full function at line 1535

    function getLastUpdate($fieldname=null){

    if (!$fieldname) $fieldname = 'created';

    $db = &JFactory::getDBO();

    $query = "SELECT `$fieldname` FROM #__content a ORDER BY `$fieldname` DESC LIMIT 1";

    $db->setQuery($query);

    $data = $db->loadObject();

    if( $data->$fieldname ){ //return gmdate( 'h:i:s A', strtotime($data->created) ) .' GMT ';

    $date =& JFactory::getDate(strtotime($data->$fieldname));

    //get timezone configured in Global setting

    $app = & JFactory::getApplication();

    $tz = $app->getCfg('offset')*60*60;

    $sec =$date->toUNIX(); //set the date time to second

    //return by the format defined in language

    return strftime (JText::_('T3_DATE_FORMAT_LASTUPDATE'), $sec+$tz);

    }

    return ;

    }

    replace that with

    function getLastUpdate() {

    $db = &JFactory::getDBO();
    $nullDate = $db->getNullDate();
    // last modified
    $query = 'SELECT modified AS date FROM #__content AS c WHERE c.state = 1 ORDER BY modified DESC LIMIT 1';
    $db->setQuery($query);
    $modified = $db->loadObject();
    // last created
    $query = 'SELECT created AS date FROM #__content AS c WHERE c.state = 1 ORDER BY created DESC LIMIT 1';
    $db->setQuery($query);
    $created = $db->loadObject();

    if ($modified->date == $nullDate || $modified->date < $created->date) {
    $date = $created->date;
    } else {
    $date = $modified->date;
    }

    if ($date){
    $user =& JFactory::getUser();
    if ($user->getParam('timezone')) {
    $offset = $user->getParam('timezone');
    } else {
    $conf =& JFactory::getApplication();
    $offset = $conf->getCfg('offset');
    }
    $format = 'd.m.Y (h:i)'; // dd-mm-yyyy (hh:mm); like: 03.11.2010 (09:47)
    return JHTML::_('date', $date, $format);
    }
    return;
    }

    that will show the time of the latest updated time based on your settings in configuration.php and correct time zone…

    hope it helps few of you who were wondering.

    and if you want the 24 hour clock showed just replace (h:i) with (H:i)

    ricky_wid Friend
    #386046

    I can,t found code like you said above, I just found the similar code like this:

    function getLastUpdate(){
    $db = &JFactory::getDBO();
    $query = 'SELECT created FROM #__content a ORDER BY created DESC LIMIT 1';
    $db->setQuery($query);
    $data = $db->loadObject();
    if( $data->created ){ //return gmdate( 'h:i:s A', strtotime($data->created) ) .' GMT ';
    $date =& JFactory::getDate(strtotime($data->created));
    $user =& JFactory::getUser();
    $tz = $user->getParam('timezone');
    $sec =$date->toUNIX(); //set the date time to second
    return gmdate("h:i:s A", $sec+$tz).' GMT';
    }
    return ;
    }

    and code line just until 829 and no go more until 1535

    Thanks

    splico123 Friend
    #386121

    <em>@ricky_wid 233823 wrote:</em><blockquote>I can,t found code like you said above, I just found the similar code like this:

    function getLastUpdate(){
    $db = &JFactory::getDBO();
    $query = 'SELECT created FROM #__content a ORDER BY created DESC LIMIT 1';
    $db->setQuery($query);
    $data = $db->loadObject();
    if( $data->created ){ //return gmdate( 'h:i:s A', strtotime($data->created) ) .' GMT ';
    $date =& JFactory::getDate(strtotime($data->created));
    $user =& JFactory::getUser();
    $tz = $user->getParam('timezone');
    $sec =$date->toUNIX(); //set the date time to second
    return gmdate("h:i:s A", $sec+$tz).' GMT';
    }
    return ;
    }

    and code line just until 829 and no go more until 1535

    Thanks</blockquote>

    Which Template are you using? and version of the framework? i am using the joomla 1.6 the latest framework and thats what is says…

    check please and i will provide you with updated code, but even if you try replace that one with the one i posted it should work.

    Paul Wallen Friend
    #386696

    Same problem here, the code only goes to line 828.

    retsis Friend
    #441756

    <em>@splico123 233751 wrote:</em><blockquote>

    function getLastUpdate() {

    $db = &JFactory::getDBO();
    $nullDate = $db->getNullDate();
    // last modified
    $query = 'SELECT modified AS date FROM #__content AS c WHERE c.state = 1 ORDER BY modified DESC LIMIT 1';
    $db->setQuery($query);
    $modified = $db->loadObject();
    // last created
    $query = 'SELECT created AS date FROM #__content AS c WHERE c.state = 1 ORDER BY created DESC LIMIT 1';
    $db->setQuery($query);
    $created = $db->loadObject();

    if ($modified->date == $nullDate || $modified->date < $created->date) {
    $date = $created->date;
    } else {
    $date = $modified->date;
    }

    if ($date){
    $user =& JFactory::getUser();
    if ($user->getParam('timezone')) {
    $offset = $user->getParam('timezone');
    } else {
    $conf =& JFactory::getApplication();
    $offset = $conf->getCfg('offset');
    }
    $format = 'd.m.Y (h:i)'; // dd-mm-yyyy (hh:mm); like: 03.11.2010 (09:47)
    return JHTML::_('date', $date, $format);
    }
    return;
    }

    that will show the time of the latest updated time based on your settings in configuration.php and correct time zone…

    hope it helps few of you who were wondering.

    and if you want the 24 hour clock showed just replace (h:i) with (H:i)</blockquote>

    I used the above code for Europe/Athens timezone (already used in configuration.php) but unfortunately the time appears is minus 2 from my real time. I use Ja nex template, joomla 2.5 version. Any ideas? Thank you in advance.

    splico123 Friend
    #443421

    For joomla 2.5 its fairly simple update, depending if you want to show date or time just update this as to your liking:

    function getLastUpdate($fieldname = null)
    {
    if (! $fieldname) $fieldname = 'created'; //------------------ for modified date change 'created' to 'modified'
    $db = &JFactory::getDBO();
    $query = "SELECT `$fieldname` FROM #__content a ORDER BY `$fieldname` DESC LIMIT 1"; //------------------ for k2 items to show, change the '#__content' to 'xxx_k2_items' where xxx is your db prefix.
    $db->setQuery($query);
    $data = $db->loadObject();
    if ($data != null && $data->$fieldname) {
    $date = JFactory::getDate($data->$fieldname);
    //get timezone configured in Global setting
    $app = & JFactory::getApplication();
    // Get timezone offset
    $tz = $app->getCfg('offset');
    // Set timezone offset for date
    $date->setTimezone(new DateTimeZone($tz));
    //return by the format defined in language
    $format = 'd.m.Y (h:i)'; // --------------------------------- dd-mm-yyyy (hh:mm); like: 03.11.2010 (09:47) -------------------------
    return JHTML::_('date', $date, $format);
    return $date->toFormat(JText::_('T3_DATE_FORMAT_LASTUPDATE'), true);
    }
    return;
    }

    hope it helps to some of you

Viewing 6 posts - 1 through 6 (of 6 total)

This topic contains 6 replies, has 4 voices, and was last updated by  splico123 12 years, 8 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum