-
AuthorPosts
-
gray Friend
gray
- Join date:
- October 2009
- Posts:
- 957
- Downloads:
- 0
- Uploads:
- 17
- Thanks:
- 28
- Thanked:
- 292 times in 230 posts
January 16, 2010 at 6:16 pm #147713The issue is that “Last Update” data at the top differs from the date shown on the newest article.
I’ve created an alternative getLastUpdate function to fix the issue (file ja.template.helper.php)
[php]
# Get time of last updated article Hacked by Gray
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 ){
$user =& JFactory::getUser();
if ($user) {
$offset = $user->getParam(‘timezone’);
} else {
$offset = NULL;
}
$format = ‘%d.%m.%Y %H:%M’;
return JHTML::_(‘date’, $data->created, $format, $offset);
} else {
return ”; // emtpy string
}
}
[/php]3 users say Thank You to gray for this useful post
ithacaindy Friendithacaindy
- Join date:
- January 2010
- Posts:
- 335
- Downloads:
- 0
- Uploads:
- 10
- Thanks:
- 20
- Thanked:
- 12 times in 1 posts
January 31, 2010 at 6:06 pm #331058<em>@gray 160685 wrote:</em><blockquote>The issue is that “Last Update” data at the top differs from the date shown on the newest article.
I’ve created an alternative getLastUpdate function to fix the issue (file ja.template.helper.php)
</blockquote>
Do I create this file – and where do I save it?
gray Friendgray
- Join date:
- October 2009
- Posts:
- 957
- Downloads:
- 0
- Uploads:
- 17
- Thanks:
- 28
- Thanked:
- 292 times in 230 posts
January 31, 2010 at 6:43 pm #331061This function already exists in file
file templatesja_teline_iiilibsja.template.helper.phpYou should replace existing funtion with the new one (please keep back-ups of all files being modified!)
ithacaindy Friendithacaindy
- Join date:
- January 2010
- Posts:
- 335
- Downloads:
- 0
- Uploads:
- 10
- Thanks:
- 20
- Thanked:
- 12 times in 1 posts
January 31, 2010 at 10:30 pm #331071There’s a problem with the alternative function; a missplaced } somewhere. I restored the original file.
gray Friendgray
- Join date:
- October 2009
- Posts:
- 957
- Downloads:
- 0
- Uploads:
- 17
- Thanks:
- 28
- Thanked:
- 292 times in 230 posts
February 1, 2010 at 5:56 am #331125<em>@ithacaindy 162870 wrote:</em><blockquote>There’s a problem with the alternative function; a missplaced } somewhere. I restored the original file.</blockquote>
This function works on my site, and it does not have problems with missing or additional “}”
You should replace the entire function getLastUpdate with the new code.ithacaindy Friendithacaindy
- Join date:
- January 2010
- Posts:
- 335
- Downloads:
- 0
- Uploads:
- 10
- Thanks:
- 20
- Thanked:
- 12 times in 1 posts
February 1, 2010 at 5:00 pm #331227The new function doesn’t create any errors. However, the update time doesn’t match the last post’s time. Additionally, the time still says “GMT”; I’d like it to be my EST default, as set in global preferences.
gray Friendgray
- Join date:
- October 2009
- Posts:
- 957
- Downloads:
- 0
- Uploads:
- 17
- Thanks:
- 28
- Thanked:
- 292 times in 230 posts
February 2, 2010 at 5:45 am #331267<em>@ithacaindy 163054 wrote:</em><blockquote>The new function doesn’t create any errors. However, the update time doesn’t match the last post’s time. Additionally, the time still says “GMT”; I’d like it to be my EST default, as set in global preferences.</blockquote>
It uses Joomla’s function JHTML::_(‘date’, $data->created, $format, $offset) to return formatted date.
If last post time doesn’t match, see if correct time zone is set in Global Configurations.
As regards ‘GMT’ it should not appear, as $format = ‘%d.%m.%Y %H:%M’ has no “GMT” attached.ithacaindy Friendithacaindy
- Join date:
- January 2010
- Posts:
- 335
- Downloads:
- 0
- Uploads:
- 10
- Thanks:
- 20
- Thanked:
- 12 times in 1 posts
February 2, 2010 at 2:42 pm #331317The Global Configurations/Server/Locale Settings is set to UTC -05:00 (Eastern Time). The last update says “Last update: 09:00:01 AM GMT”.
gray Friendgray
- Join date:
- October 2009
- Posts:
- 957
- Downloads:
- 0
- Uploads:
- 17
- Thanks:
- 28
- Thanked:
- 292 times in 230 posts
February 3, 2010 at 5:26 am #331358Very strage.. The new function has $format = ‘%d.%m.%Y %H:%M’ (that is Dya.Month.Year Hour:Minutes) and no “GMT” string.
Have you replaced the old funtion getLastUpdate in ja.template.helper.php with the new one?hcardenas Friendhcardenas
- Join date:
- February 2010
- Posts:
- 41
- Downloads:
- 12
- Uploads:
- 14
- Thanks:
- 20
- Thanked:
- 6 times in 3 posts
February 27, 2010 at 12:52 am #334068Thank you very much, Gray. it worked fine!!
tgtff Friendtgtff
- Join date:
- April 2009
- Posts:
- 42
- Downloads:
- 4
- Uploads:
- 1
- Thanks:
- 10
- Thanked:
- 2 times in 1 posts
April 7, 2010 at 12:26 pm #339480This new code worked well for me – the correct date and time are now showing.
However what does have a problem with this format is when you schedule articles i.e. for the future. The last update actually appears as the future article date and time.
Any ideas on how to fix that?
many thanks
gray Friendgray
- Join date:
- October 2009
- Posts:
- 957
- Downloads:
- 0
- Uploads:
- 17
- Thanks:
- 28
- Thanked:
- 292 times in 230 posts
April 7, 2010 at 4:16 pm #339501To tgtff
Time is selected by the code:
[PHP] $query = ‘SELECT created FROM #__content a ORDER BY created DESC LIMIT 1’;[/PHP]Do you put “Created” date in future?
August 18, 2010 at 12:56 pm #353063Doesn’t work properly for me.
Offset is set +1 (i.e. Amsterdam). But the function ignores this. Last update shows 13.40. Should be 14.40.
I have replaced the whole old function. And the Global Configurations > Server > Locale Settings is set to UTC +01:00.
Any ideas?
Thanks, Jelger
Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
August 19, 2010 at 4:40 am #353127<em>@gray 160685 wrote:</em><blockquote>The issue is that “Last Update” data at the top differs from the date shown on the newest article.
I’ve created an alternative getLastUpdate function to fix the issue (file ja.template.helper.php)
[php]
# Get time of last updated article Hacked by Gray
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 ){
$user =& JFactory::getUser();
if ( $user ) {
$offset = $user->getParam(‘timezone’);
} else {
$offset = NULL;
}
$format = ‘%d.%m.%Y %H:%M’;
return JHTML::_(‘date’, $data->created, $format, $offset);
} else {
return ”; // emtpy string
}
}
[/php]</blockquote>The above solution is to follow the user’s Timezone when user logins the site. I suggest some extra changes to follow both the System’s Time Zone and the user’s Timezone:
a) change code:
[PHP]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 ){
$user =& JFactory::getUser();
if ( $user->getParam(‘timezone’) ) {
$offset = $user->getParam(‘timezone’);
} else {
$conf =& JFactory::getConfig();
$offset = $conf->get(‘config.offset’);
}
$format = ‘%d.%m.%Y %H:%M’;
return JHTML::_(‘date’, $data->created, $format, $offset);
} else {
return ”; // emtpy string
}
}
[/PHP]b) update system ‘s TimeZone: Go to Administrator => Site => Global Configuration and choose tab Server and then update the Time Zone in Locale Settings
-
AuthorPosts
This topic contains 17 replies, has 8 voices, and was last updated by firon 14 years, 1 month ago.
We moved to new unified forum. Please post all new support queries in our New Forum