Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

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

Userpage - problems with relative date showing in admin


Reply

2 Posts   772 Views

Avatar
bellafaith

3 March 2010 at 11:12am Community Member, 12 Posts

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');

Avatar
bellafaith

5 March 2010 at 8:36pm (Last edited: 5 March 2010 8:37pm), Community Member, 12 Posts

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 [URL="http://silverstripe.org/archive/show/220545#post220545"]this post[/URL] & 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)"!