Sonataadminbundle: sonata_type_date_picker gives incorrect date

Created on 14 Dec 2014  路  13Comments  路  Source: sonata-project/SonataAdminBundle

Always when i edit my entity sonata_type_date_picker gives incorrect date
screen5

screen1

Information from debug toolbar
screen2

Doctrine configuration
screen4

Any workaround ?

pending author

Most helpful comment

THIS IS STILL HAPPENING! Symfony 3.2.13. Is sonata that much retarded?

k59iepb

Dude, you're yelling at software! Written by benevolent people! If there is an issue, fix it with your superior intellect and make a PR, otherwise, let me refund you the $0 you spend on this, and don't use Sonata ever again.

All 13 comments

@ENDaZONELT can you also paste here the related code from youd admin?

From admin file:
->add('saleDate', 'sonata_type_date_picker')

Entity:

    /**
     * @var \DateTime
     */
    protected $saleDate;

    function __construct()
    {
        $this->saleDate = new \DateTime();
    }

I have I think the same issue here.

My admin code is very simple:

    $formMapper->add('endMaintenance', 'date', array('widget' => 'single_text', 'required' => false,  'attr' => array('class' => 'datepicker')))

(endMaintenance is type date in db)

In DB I have 2015-07-13

selection_009

Each time the object is saved => minus 1 day...

workaround:

$formMapper->add('endMaintenance', 'datetime', array('widget' => 'single_text', 'required' => false,  'attr' => array('class' => 'datepicker')))

I cannot reproduce the issue.

@ENDaZONELT @bobman38 can you please test your code with current master version of SonataCoreBundle, SonataAdminBundle and SonataDoctrineORMAdminBundle if this bug still exists?

I have the same issue here

sonata-project/core-bundle                 2.3.3
sonata-project/admin-bundle                2.3.3
sonata-project/doctrine-orm-admin-bundle   2.3.2

Only list and show actions are buggy for me .. edit form has the right value displayed

@pulzarraider Just tested with master version .. same issue

I think the problem could be the timezone

Model Format    same as normalized format
Normalized Format   
Object(DateTime) - 2015-04-30T00:00:00+0200
View Format 
Apr 30, 2015

My guess is the +0200 has something to do ..

It may be related to this symfony bug. It's already fixed.
symfony/symfony#12808

@jsampedro77 is right. Just upgrade your Symfony version.

:+1:

THIS IS STILL HAPPENING! Symfony 3.2.13. Is sonata that much retarded? Workaround shown above not work. But this works for me:

->add('dateSince', 'sonata_type_datetime_picker', [
    'required' => false,
    'dp_pick_time' => false,
    'format' => DateType::HTML5_FORMAT
])

THIS IS STILL HAPPENING! Symfony 3.2.13. Is sonata that much retarded?

k59iepb

Dude, you're yelling at software! Written by benevolent people! If there is an issue, fix it with your superior intellect and make a PR, otherwise, let me refund you the $0 you spend on this, and don't use Sonata ever again.

Well, it was impressive bombardment by me, too emotional actually, but it is cumulative effect of many silently silenced "WTF?!" exclamations. I refused to use Sonata but it is used in current project, so..
Cool gif tho))

Was this page helpful?
0 / 5 - 0 ratings