date problem after upgrade

Permalink 1 user found helpful
I've upgraded my site from 5.3.2 to 5.3.3 but now I've got a date problem.

I'm trying to present the Collection date of a Concrete page like this 2009-10-05, it worked when I was running 5.3.2, but after the upgrade it show the full date, included time.

This is my code
$cobj->getCollectionDatePublic("Y-m-d")

It should give me 2009-10-05, but it shows me this: 2009-10-05 11:34:00

Can anybody tell how i can fix this? Thanks!

NUL76
 
ryan replied on at Permalink Best Answer Reply
ryan
There were some inconsistencies in how the different objects treated & formatted date/times. With 5.3.3 there is now timezone support, so internal functionality & date/time comparisons use the system time and outputting to the screen you'd use the user time.

Here's the function that you're calling:
<?php
/**
 * Gets the date a the current version was made public, 
 * if user is specified, returns in the current user's timezone
 * @param string $type (system || user)
 * @return string date formated like: 2009-01-01 00:00:00 
*/
function getCollectionDatePublic($type='system') {
    if(ENABLE_USER_TIMEZONES && $type == 'user') {
        $dh = Loader::helper('date');
        return $dh->getLocalDateTime($this->vObj->cvDatePublic);
    } else {
        return $this->vObj->cvDatePublic;
    }
}


So, to get it formatted correctly you'd do:
<?php
$ts = strtotime($cobj->getCollectionDatePublic('user'));
echo date('Y-m-d',$ts);
?>
NUL76 replied on at Permalink Reply
NUL76
Clear answer and it works!
Thanks