Jump to:

520 Posts in 248 Topics by 263 members

Content Editor Discussions

SilverStripe Forums » Content Editor Discussions » DateTimeField keeps converting times to AM

Forum for content editors and CMS users.

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

Page: 1
Go to End
Author Topic: 175974 Views
  • Dig
    Avatar
    Community Member
    29 Posts

    DateTimeField keeps converting times to AM Link to this post

    In the time part of the date time field it always converts the time to AM no matter what is put in there. I notice it used strtotime so I've tried all sorts of creative entry to get a PM time but it simply doesn't work.

    21:15 -> save -> 9:15:00 AM

    9:15:00 PM -> save -> 9:15:00 AM

    and plenty more.

    This is in a dataobject managed by model admin, silverstripe 3.1 but we've tried 3, 3.0.5 and 3.1 in this process with the same results.

    Any ideas, going a bit loopy here being stuck on such a simple seeming issue!

    Cheers,

  • Devlin
    Avatar
    Community Member
    215 Posts

    Re: DateTimeField keeps converting times to AM Link to this post

    I can reproduce this issue.

    As a workaround, you can edit the time format to a 24h format.

    $datetime = new DatetimeField('Datetime');
    $datetime->timefield->setConfig('timeformat', 'H:mm');
    // or
    $time = new TimeField('Time');
    $time->setConfig('timeformat', 'H:mm');

    Edit:
    Maybe related to #1713.

  • tractorcow
    Avatar
    Community Member
    14 Posts

    Re: DateTimeField keeps converting times to AM Link to this post

    Pull request in https://github.com/silverstripe/silverstripe-framework/pull/2164

    Hopefully this fixes the issue.

    The problem was due to the TimeField mistakenly assuming times with am/pm were in ISO format (24 hour format) and converting them using this method. Sadly, this dropped the am/pm.

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: DateTimeField keeps converting times to AM Link to this post

    The fix mentioned above has been merged into the 3.1 branch and so will be included with 3.1.0-rc1

    175974 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.