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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

Changing the date field to US format


Go to End


9 Posts   5575 Views

Avatar
sonicparke

74 Posts

29 November 2007 at 10:47am

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.

Avatar
Ingo

Forum Moderator, 801 Posts

29 November 2007 at 1:20pm

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?

Avatar
sonicparke

74 Posts

30 November 2007 at 4:01am

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.

Avatar
sonicparke

74 Posts

30 November 2007 at 7:49am

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?

Avatar
Ingo

Forum Moderator, 801 Posts

30 November 2007 at 9:00am

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

Avatar
sonicparke

74 Posts

30 November 2007 at 9:17am

OK. I'll look for that.

Avatar
sonicparke

74 Posts

3 December 2007 at 4:02pm

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?

Avatar
areikiera

Community Member, 26 Posts

27 February 2008 at 4:23am

Edited: 27/02/2008 5:22am

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!

Go to Top