format date in editor

format date in editor

AloneInTheDarkAloneInTheDark Posts: 30Questions: 7Answers: 0
edited March 2016 in Free community support

Hi,
i have a two fields date and datatime. I recive this date from php : 2016-03-07T08:28:00+0000
and i want format like DD-MM-YYYY HH:MM:SS. My settings are (editor):

fields: [
....
{
 label: "Date",
 name: "data1",
 type: "date",
 format: "dd-mm-yy",
 def:    function () 
     {
       var date=moment().format('DD-MM-YYYY');
       return date;
     },
},
{
 label: "Date",
 name: "data2",
 type: "datetime",
 format: "DD-MM-YYYY HH:mm:ss",
 def:    function () 
     {
       var date=moment().format('DD-MM-YYYY');
       return date;
     },
},
....

but field datetime show "2016-03-07T08:28:00+0000"
and date show "2015-12-30" in update form, but when add a record
is OK.
Why?

tnk

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Replies

  • allanallan Posts: 63,095Questions: 1Answers: 10,389 Site admin

    I would suggest that you perform the formatting on the server-side using the formatting functions. The datetime field type won't convert from one form to another, it just uses a single form.

    Allan

  • AloneInTheDarkAloneInTheDark Posts: 30Questions: 7Answers: 0
    edited March 2016

    Hi Allan,
    i use my php class and output is json string, like this:

    ....
    {
        "DT_RowId": "51",
        "id_msg": 51,
        "id_user": 32,
        "level": true,
        "title": "AAAAAA",
        "message": "BBBBBB",
        "enabled": true,
        "data_view": "01-03-2016",
        "start_publication": "07-03-2016 08:28:00",
        "end_publication": "14-03-2016 08:28:00",
        "dateIT": "01-03-2016",
        "dateEN": "2016-03-01",
        "u": {
            "name": "123"
        },
        "r": {
            "description": "Admin"
        }
    },
    ....
    

    but when i open update form show "2016-03-07T08:28:00+0000"
    :(
    help!

  • allanallan Posts: 63,095Questions: 1Answers: 10,389 Site admin

    Could you give me a link to the page so I can take a look and see what is going wrong please?

    For the default - you can just return a Date object - you don't need to format it (and if you did you would need to format it to match the full format).

    Thanks,
    Allan

This discussion has been closed.