Topic: PHPMyAdmim - Format Date - DropdownListboxes

Hello,

On my view/admin/new.rhtml & edit.rhtml pages my date dropdown list boxes (3 of them) are in the format of YYYY-MM-DD.

On the back end of the database it is the same format. You can not change it to a different format.

I looked at the system variables in PHPMyAdmin and the Date Format is "%Y-%m-%d"

I tried to find some documentation on changing this using the console, but to no avail.

How do I change the format on my backend?
Or... how do I go about having it display correctly??

Here is my view/admin/_form.rhtml

<%= error_messages_for 'code' %>

<!--[form:code]-->
<p><label for="code_create_date">Date Created</label><br/>
<%= date_select 'code', 'create_date'  %></p>

<p><label for="code_category">Category</label><br/>
<%= collection_select :code, :category_id, Category.find(:all), :id, :category %></p>

<p><label for="code_title">Title</label><br/>
<%= text_field 'code', 'title'  %></p>

<p><label for="code_code">Code</label><br/>
<%= text_area 'code', 'code'  %></p>
<!--[eoform:code]-->


FYI... I would rather change it on the backend. I want the default value to be "%m-%d-%Y"

Thanks
smile

Last edited by fwhilton (2007-01-27 21:05:26)

Re: PHPMyAdmim - Format Date - DropdownListboxes

According to http://dev.mysql.com/doc/refman/4.1/en/datetime.html

DateTime can not be changed in mySQL... what is with that???  sad

So, then that means I have to display the dropdown list in the appropiate format...

%m-%d-%Y  (currently they are yyyy-dd-mm)

Thanks

Re: PHPMyAdmim - Format Date - DropdownListboxes

Well... I did figure out the list and show rhtml's

...
...
<td><%= code["create_date"].strftime("%m-%d-%Y") %></td>
...
...

But, now i need to figure out how to get the dropdown list to display in the mm-dd-yyyy order.

We keep going!

smile

Re: PHPMyAdmim - Format Date - DropdownListboxes

Try the :order parameter of date_select:

<%= date_select 'code', 'create_date', :order => [:month, :day, :year]  %></p>

Railscasts - Free Ruby on Rails Screencasts

Re: PHPMyAdmim - Format Date - DropdownListboxes

ryanb wrote:

Try the :order parameter of date_select:

<%= date_select 'code', 'create_date', :order => [:month, :day, :year]  %></p>

Perfect!!! That was it!

What documentation can I find all the DATE format codes in??

Thanks
smile

Re: PHPMyAdmim - Format Date - DropdownListboxes

Check out the Rails API. I wouldn't call it complete, but it has hints of what is possible.

Railscasts - Free Ruby on Rails Screencasts