Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Userpage - problems with relative date showing in admin

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 752 Views
  • bellafaith
    Avatar
    Community Member
    12 Posts

    Userpage - problems with relative date showing in admin Link to this post

    Wasn't sure what topic to put this in - I'm using userpage but this is actually a problem I'm experiencing after customizing it.

    I'm having a difficult time with date output in the back-end. It's probably a simple solution, but my mind has been spinning for hours trying to solve it. So hopefully someone can help me. I'm using userpage module for registering users. I want to display the date the user has registered in the member's profile that is seen by the admin (under Security & viewing user details). I have finally been able to have the date displayed in US format (m/d/Y). The problem I am having is the relative time is showing up when logged in as admin & it is wrong.

    Example: If I register today, March 2, 2010, the date automatically is displayed as 03/02/2010 (this is displayed both in the front-end of the site at the user's profile & in the back-end under Security, when viewing user's details as admin). However, in the back-end it also displays the relative time, so it says "03/02/2010, 2 months ago". (It does not list the relative time in the user's profile on the front-end).

    I would be happy with a solution that either makes the relative date correct (which should be "Today"), or one that removes the relative date from appearing in the back-end. But I can't seem to get a solution on my own.

    I'm currently using the Database field type Date & I'm using this in onBeforeWrite():

    date_default_timezone_set('America/Chicago');
    $this->DateRegistered = date('m/d/Y');

  • bellafaith
    Avatar
    Community Member
    12 Posts

    Re: Userpage - problems with relative date showing in admin Link to this post

    I finally got the date to show correctly (in US format) AND get the relative date to match. After taking some time to clear my mind, I found this post & followed SmartPlugsDesign's instructions for better US localization. I did have to change my bit of code that I posted previously to "d/m/Y" in order for it to display "m/d/Y":

    $this->DateRegistered = date('d/m/Y');

    But it works & now displays "03/05/2010 (today)"!

    752 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.