Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Changing the date field to US format

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 4699 Views
  • sonicparke
    Avatar
    74 Posts

    Changing the date field to US format Link to this post

    I'm having the hardest time changing the format of the date that is returned when you select it from the calendar in the form date field. I've changed everything I could see in Date.php & DateField.php. My global date format hasn't changed either. I have flushed the DB & admin & site multiple times.

    Is it possible to change the format for this? It seems like a relatively simple thing to do.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Changing the date field to US format Link to this post

    looks like you're on the right track with subclassing stuff (at least until we've got proper field-localization going). DateField.php and Date.php should be the only relevant classes here - can you step through the saving/loading process and see at which point the date-format changes?

  • sonicparke
    Avatar
    74 Posts

    Re: Changing the date field to US format Link to this post

    I guess I can change one thing at a time and see if anything happens. I thought I had already changed everything that made sense and it didn't seem to affect anything. But I'll try it again with a different approach.

  • sonicparke
    Avatar
    74 Posts

    Re: Changing the date field to US format Link to this post

    I'm still getting nowhere. I can see where i can change the format for the Nice function. I just can't figure out how to get the Nice function working when it returns the date chosen from the calendar into the text box. I can't seem to figure out where all this happens. I'm assuming I'd find a return $Date somewhere that I could Nice Method to and that would be it.

    Is that the right way to do this & if so what file is this in?

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Changing the date field to US format Link to this post

    ah, so we're talking about a CalendarDateField? thats a bit more tricky, you probably need to look at the javascript-logic as well

  • sonicparke
    Avatar
    74 Posts

    Re: Changing the date field to US format Link to this post

    OK. I'll look for that.

  • sonicparke
    Avatar
    74 Posts

    Re: Changing the date field to US format Link to this post

    OK. I'd like to know if anyone has been successful at changing the date format in the stable release of 2.2.0. I was messing with it on 2.2.0-rc2 and it changes just fine. It has been a couple of days since I made the changes and noticed that it was working.

    So either there is a bug with the stable version that wasn't in rc2 or it takes several hours to a couple of days to take effect.

    Has anyone successfully changed the date format to US?

  • areikiera
    Avatar
    Community Member
    26 Posts

    Re: Changing the date field to US format Link to this post

    I've successfully changed the CalendarDateField to the American Date Format.

    I changed this file: jsparty\calendar\calendar-setup.js

    In line 5, change "ifFormat : %d/%m/%Y" to "ifFormat : %m/%d/%Y"

    It doesn't appear to work at first, but flush the cache and it will show up after you select a date from the pop-up calendar.

    Hope this helps!

    4699 Views
Page: 1 2
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.