-
AuthorPosts
-
splico123 Friend
splico123
- Join date:
- January 2007
- Posts:
- 339
- Downloads:
- 80
- Uploads:
- 7
- Thanks:
- 24
- Thanked:
- 93 times in 16 posts
April 12, 2011 at 7:10 pm #162715there 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 Friendricky_wid
- Join date:
- April 2009
- Posts:
- 46
- Downloads:
- 0
- Uploads:
- 5
- Thanks:
- 8
- Thanked:
- 2 times in 1 posts
April 13, 2011 at 5:18 am #386046I 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 Friendsplico123
- Join date:
- January 2007
- Posts:
- 339
- Downloads:
- 80
- Uploads:
- 7
- Thanks:
- 24
- Thanked:
- 93 times in 16 posts
April 13, 2011 at 9:24 am #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 FriendPaul Wallen
- Join date:
- September 2014
- Posts:
- 140
- Downloads:
- 0
- Uploads:
- 13
- Thanks:
- 35
- Thanked:
- 5 times in 1 posts
April 16, 2011 at 10:45 pm #386696Same problem here, the code only goes to line 828.
March 4, 2012 at 3:01 pm #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 Friendsplico123
- Join date:
- January 2007
- Posts:
- 339
- Downloads:
- 80
- Uploads:
- 7
- Thanks:
- 24
- Thanked:
- 93 times in 16 posts
March 13, 2012 at 11:31 am #443421For 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
-
AuthorPosts
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