How would I change the "posted 1234 Days ago", to "posted on Dec 20, 2011" on Elgg 1.8? Thanks
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
Yeah, there's no errors in the file as it's posted. Chris are you sure that's an exact copy?
ok that worked, I've been doing it from my iphone so that was probobably the problem somehow, you guys are the best. I'll package it up soon and upload it.
Not to put any pressure on you, but to make it extensible for other people you might consider adding support for a variety of formats.
To accomplish this, you would need a settings page for an admin to choose their format. This setting would be saved as a "plugin setting".
Then in the friendlytime hook you would check the plugin setting and format the output as necessary.
... if you're up for the challenge/learning curve
I'll consider it Matt, hope I'm not pushing my luck here, but how would I make it so if something was posted today it would read "Today at 2:44am", and if it was posted yesturday, te same but obviously te word yesturday, then the date and time posted if later than yesturday? I looked in the engine/lib directory but am not sure how to display te time, thanks Alot.
No help?
http://php.net/manual/en/function.date.php
It's nothing to do with engine/lib
Everything you need to do has already been done in the hook we created, just add new if statements for logic and use the link Dhrup posted to format your date.
is is that hard ?
Here is the code I tried
<?php
elgg_register_event_handler('init', 'system', 'friendlytime_init');
function friendlytime_init() {
elgg_register_plugin_hook_handler('format', 'friendly:time', 'friendlytime_hook_handler');
}
function friendlytime_hook_handler($hook, $type, $return, $params) {
if($params['time'] > (time() - 60*60*24)){
return 'Today at D, d M Y H:i';
} else {
return "Yesturday at D, d M Y H:i"; }
else {
$old_time = $params['time'];
$mdy = date("M j, Y", $old_time);
$hm = date("g:ia", $old_time);
$new_time_readable = elgg_echo('friendly_time', array($mdy, $hm));
return $new_time_readable;
}
the return wont show the time, only the "Yesturday at D, d M Y H:i" as raw code, and the default date and time if posted longer than two days ago doesnt show at all.
you coded --
return 'Today at D, d M Y H:i';
} else {
return "Yesturday at D, d M Y H:i"; }
oh boy ! ;-P
you didn't read any of that stuff in that link i sent above, didya ?
suggest that you do yourself a favor and go back to read that well, it's very well written !
- Previous
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- Next
You must log in to post replies.