Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

Categories

In this Discussion

Who's Online 9

ericgilletteluc +7 guests

user account created on ?

when i look at my admin user...there is an actual date displayed like "Jun 22nd 2005" but for every other user ther is "x hours, minutes or whatever ago" any idea why that could be? by the way i noticed that in this forum there is also a sort of inconsistency...try to search for users and leave the texfield blank...then you can see...some accounts say created 5 days ago and some have dates displayed. i dont know why this is...maybe its obvious but not for me :D

Comments

  • Posts: 703
    there is probably a threshold... like anything created in the last week get's displayed as "4 days ago" and anything over a week get's displayed as the actual date.
  • Posts: 5,574
    i believe when it goes over a certain time period it just displays the date.
  • BenBen
    Posts: 534
    i think anything over 7 days gets an actual date
  • Posts: 703
    omg echo?
  • Posts: 101
    is it the same with topic timestamps and so on? i just wondered because rails handles it the way that it displays weeks and months and even years after some time with the function "time_in_words_ago" yeah yeah i know this is php and no ruby/rails forum but i just thought it might behave the same :D
  • BenBen
    Posts: 534
    we're all just too fast jonezy
  • Posts: 5,574
    ichigo i'm pretty sure that mark will have coded it to act that way and that its not actually a php function. Though i could be completely wrong.
  • Posts: 101
    yeah i also dont know a php function that does something like that...but please correct me if im wrong :)
  • Posts: 703
    here is how it is done.

    <dd>".TimeDiff($this->User->DateFirstVisit, mktime())."</dd>

    though that is from the account.php file i imagine it's the same everywhere else.
  • Posts: 5,574
    but is TimeDiff a function that mark's created? php.net says yes. In which case you could quite easily change it i think.
  • Posts: 101
    thanks for explaining :) it makes things clearer to me
  • Posts: 5,574
    p.s: function TimeDiff($Time, $TimeToCompare = "") { if ($TimeToCompare == "") $TimeToCompare = time(); $Difference = $TimeToCompare-$Time; $Days = floor($Difference/60/60/24); $Difference -= $Days*60*60*24; $Hours = floor($Difference/60/60); $Difference -= $Hours*60*60; $Minutes = floor($Difference/60); $Difference -= $Minutes*60; $Seconds = $Difference; if ($Days > 7) { return date("M jS Y", $Time); } elseif ($Days > 0) { return FormatPlural($Days, "day ago", "days ago"); } elseif ($Hours > 0) { return FormatPlural($Hours, "hour ago", "hours ago"); } elseif ($Minutes > 0) { return FormatPlural($Minutes, "minute ago", "minutes ago"); } else { return FormatPlural($Seconds, "second ago", "seconds ago"); } }
  • Posts: 703
    holy shit we were all bang on
  • Posts: 5,574
    As you can see, if you wanted to show the length of time ago regardless, you just need to play around with that if statement at the bottom there.
  • Posts: 101
    yeah that wont be to hard...thank you :)
  • Posts: 5,574
    p.s. If you need it, that function is in library/Utility.Functions.php - though i'm almost certain you could just re-define it in an extension and that'd take priority.
This discussion has been closed.