11 years ago
4
Topic

Hi All,

I tried to change the date format in Calendar field from "Y-m-d" to "m-d-Y". The data is not stored after I changed.

When the format is like Y-m-d the data is getting stored in the db, but when I change it to m-d-Y, the data is not getting stored in db.


Can someone help me how to change and what are the date formats are available with Calendar field?


Regards,

kacraj.


Get a VIP membership
46 Posts
Castor
11 years ago
0
Level 1

Hi kacraj,

Generally the calendar plugin use for storage a field from type datetime with this format (0000-00-00 00:00:00). All dates are stored with this format in your database regardless of the formatting. m-d-Y is what you see in the calendar-field in your form.

In non-core fields, you can omit the time. which will not be saved in this case.

Best regards

Castor


11 years ago
1
Level 1

Hi Castor,

I've enabled Text Input. So the users can type in the calendar field or they can select date from the calendar.

Data is stored when selecting date from the calendar.

Since I enabled the Text Input in calendar field the user can also type in. So I changed the date format to m-d-Y which will be entered as mm-dd-yyyy.

When I try to enter the date like the above format (mm-dd-yyyy), the data is not getting stored. Please help me solve this issue plz.


Regards,

kacraj.

46 Posts
Castor
11 years ago
0
Level 2

Hi kacraj,

You are right. The date is not stored in the database because is not a valid datetime. In your case you have to change your storagefield in your database - instead datetime you can use vachar (50) - in your constructionform you can find in section storage  a checkbox "Alter". Activate it. Now in the selectbox you can choose vachar (50).

Attention: The date is not valid and is processed as a text string. You have to check the entries themselves.

Never change core-fields


I can not recommend this way. Let your input-field on read-only and it works.

Best regards

Castor






11 years ago
0
Level 1

Hi kacraj,

Thank you for your post.

Our reasoning when we develop the calendar plugin is to dissociate the stored data (date) and how to display it on a form and / or on a content view. Why ? We need to save date in this format 0000:00:00 00:00:00 in order to have possibility to translate it in any language.

In this context, i advise to set parameter "Text Input" on value "read only"; Then, you should set value m-d-Y on the parameter "format" of your field.

In this way, you will see date in this format m-d-Y but the calendar field store date in this format Y-m-d H:i:s;

If you would like to display date in the content view regarding format "m-d-Y", you sould use typo plugin "date" (when you click on button 3) in the content and/or intro view of your content type.

Regards,
Mehdi.

Get a VIP membership