Change friendly time format

How would I change the "posted 1234 Days ago", to "posted on Dec 20, 2011" on Elgg 1.8? Thanks

  • function elgg_view_friendly_time($time) {
        return elgg_view('output/friendlytime', array('time' => $time));

    So, by modifying 'view/default/output/friendlytime.php'

  • Hey there, thatnks for the response. Do I replace everything with that line? I'm on Elgg 1.8.1, thanks

  • @Chris - look at the friendlytime.php file, you'll see how the output is calculated.  You'll want to overwrite the view in a plugin with your new calculations, so copy the core file to  <yourpluginname>/views/default/output/friendlytime.php and adjust the output to your needs.

  • Thanks for the info Matt, I'm a little skittish about trying to code my own plugin as I'm not familiar with php. Maybe I'll wait for someone who knows what they're doing to make a plugin.

  • This comment was removed by an administrator because it contained advertising.

  • Create a folder "myplugin" in mod/

    Copy and edit a manifest files from any other plugin.

    Create a folder called 'views', in there create a folder 'default', in there create a folder 'output', in there create a file 'friendlytime.php'.

    Copy the following into friendlytime.php:


    $friendly_time = date("M j, Y", ($vars['time']);

    $timestamp = htmlspecialchars(date(elgg_echo('friendlytime:date_format'), $vars['time']));


    echo "<acronym title=\"$timestamp\">$friendly_time</acronym>";


    Activate your plugin. That should be it.

    I would really suggest you take a look at Elgg documentation and start learning php. Before one 1 year ago, I haven't done any programming whatsoever.

  • Hey Ismayil,

    I did everything you said and it's asking for a "start.php", so I created one and added the following code to it.

    elgg_register_action("friendlytime/views/default/output/", dirname(__FILE__) . "/friendlytime/views/default/output/friendlytime.php");

    I did read some docs and this is what I came up with, when I activate the plugin I get a white page. I'm thinking the start.php is wrong.

  • no no. you don't need to register any actions in start.php

    Just do this:

    elgg_register_event_handler('init', 'system', 'myplugin_init');

    function myplugin_init() {



    You don't need anything else in there. In the future, if you would like to register actions or extend views, you can do it in your myplugin_init function. Otherwise, leave it blank for now.


  • I posted that code in start.php and got this error

    Fatal Error.

    Redirect could not be issued due to headers already being sent. Halting execution for security. Search for more information.

  • Make sure start.php starts with <?php (no spaces before)

    Do not close start.php with ?>

Feedback and Planning

Feedback and Planning

Discussions about the past, present, and future of Elgg and this community site.