Page 1 of 2

Changing date format

Posted: Thu May 23, 2013 5:03 am
by Andrew Gilmour

Hi,

When I get data using RestXpress my dates are being returned as 2013-06-23 00:00:00 - is there an easy way to present the results as 23/06/2013 ?

Thanks

Andrew


Changing date format

Posted: Thu May 23, 2013 7:39 am
by Maryna Brodina

Hello! Try this code
codevar newDateFormat = $.datepicker.formatDate('dd/mm/yy', new Date("2013-06-23 00:00:00"));/code


Changing date format

Posted: Thu May 23, 2013 8:14 am
by Andrew Gilmour

Hi Marina,

In which part of Appery should I put this?

Andrew


Changing date format

Posted: Thu May 23, 2013 8:34 am
by Maryna Brodina

It depends on what you are going to do after you get service results. If you want to map result to some component, you would need to add codereturn $.datepicker.formatDate('dd/mm/yy', new Date(value));/code in mapping JS
This should help http://docs.appery.io/documentation/a...


Changing date format

Posted: Mon Jul 22, 2013 2:31 am
by The Herb Keeper

Hello,
I have a very similar question and I cannot solve it using the information provided, can you help?

what I am trying to do: I would like the appery backend defined date (UTC I think) to display as Month, Day, Year (or any other format). I placed the above coding (using both scripts together, and also just the first JS script from Marina) and the page breaks, so I am not doing this correctly.

I have placed this JS code into the "add JS" field in the data mapping page in appery. I have the appery backend date mapping to a specific component (in a frame) on one of my pages. can someone please tell me how to do the following:

  • add JS to somehow format the appery date output into a field that I have mapped appery backend dates into?

    thank you.


Changing date format

Posted: Mon Jul 22, 2013 3:45 am
by Alena Prykhodko

Hello! Firstly look at a similar question https://getsatisfaction.com/apperyio/...
If doen't help, please share screen shot of the mapping where you add JS?


Changing date format

Posted: Mon Jul 22, 2013 4:11 am
by The Herb Keeper

thanks so much for the quick reply. so I am not using a datepicker, but rather the date formatting is coming out of appery backend, in UTC format

I have debugged and it says the following:

--------

$.event_Date is undefined
for ( ; i < len; i++ ) {

--------

am I inserting the wrong JS or in the wrong place or both? I am so grateful for your help!!!

here are the screenshots of what I am trying to do (my project is already shared with appery support):

Image Image Image


Changing date format

Posted: Mon Jul 22, 2013 6:06 am
by Kateryna Grynko

Hi,

  1. You would need to add Datepicker component to your page. This component has functions to format the date and parse the string in a date format.

  2. In response mapping (your first screenshot), the JavaScript code (second screenshot) does not work with the return value. That is, your code in the second screenshot does not work for two reasons: formatDate as a function does not exist in your application and you can not assign a value to the component using return.

    To do this after you add Datepicker to the page (you can hide it with a flag Visible), replace the code in your second screenshot with the following:
    precode$(element)&#46;text(
    $&#46;datepicker&#46;formatDate(
    'dd&#47;mm&#47;yy', &#47;&#47; use your format here
    $&#46;datepicker&#46;parseDate(
    '!!FORMAT OF YOUR DATA!!', value
    )
    )
    );
    /code/pre
    You can find information about formatting date here: http://api.jqueryui.com/datepicker/


Changing date format

Posted: Wed Jul 24, 2013 12:59 am
by The Herb Keeper

Thank you so much Katya. I am able to map the date into the datepicker and display it. However, I am so sorry I am still struggling with two things, can you please help? you have been SO HELPFUL thank you!!:

  1. how do I map the text in the datepicker to the label I have created that is visible? I have provided a screenshot where I would like to map the hidden datepicker output.

  2. how to actually format the date - either directly in the datpicker (hidden), or in the label where I would like the date to display. can you please tell me exactly where to put that code?

    I am currently placing the above code in the JS in the data mapping for "date format" but the page keeps breaking. I have provided a screenshot here as well.

    this is the code I am using in the JS field for "date format"

    $(element).text(
    $.datepicker.formatDate(
    'D, M d yy', // my format
    $.datepicker.parseDate(
    'D, M d yy', value
    )
    )
    ); Image Image


Changing date format

Posted: Wed Jul 24, 2013 4:38 pm
by Maryna Brodina

Hello! Sorry for delay. I'll update.