Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

How to format Data object received from REST database ?

Please try the following code:
pre
code
var d = value;
console.log(d);
var d2 = new Date(d);
console.log(d2.toDateString());
return d2.toDateString();
/code
/pre

Matt6607699
Posts: 0
Joined: Sat Jan 25, 2014 7:18 am

How to format Data object received from REST database ?

I replaced my code with what you posted and it's still returning an invalid date in the console.log(d); and in the day label that the value is mapped to. Image

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

How to format Data object received from REST database ?

Matt,

This code is working for me. You can test this code using static values. Also, please try to clear browser cache.

Matt6607699
Posts: 0
Joined: Sat Jan 25, 2014 7:18 am

How to format Data object received from REST database ?

Hey, thanks for the help,
I came across this discussion and used it do get what I needed:
https://getsatisfaction.com/apperyio/...

The code I used for anyone that needs it:

var d = new Date(value.split(" ")[0]);
console.log(d); //logs "Date {Sat Mar 29 2014 20:00:00 GMT-0400 (EDT)}"
var x = d.toDateString();
console.log(x); // logs "Sat Mar 29 2014"
return x;

bahar.wadia
Posts: 0
Joined: Wed Aug 07, 2013 2:05 am

How to format Data object received from REST database ?

I am starting to have this same problem, as Matt. Something is now broken with Appery!

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How to format Data object received from REST database ?

Please provide us with more details, error screen shots will help.

bahar.wadia
Posts: 0
Joined: Wed Aug 07, 2013 2:05 am

How to format Data object received from REST database ?

I am getting the following date value returned to me "2014-05-01T00:00:00.000Z". What is the T and Z for?

Then I get an invalid date when I pass the value to Date()

Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to format Data object received from REST database ?

Hello Bahar,

The date in our base is in ISO 8601 format
http://docs.appery.io/documentation/b...
http://www.w3.org/TR/NOTE-datetime

And such code: code d = new Date('2014-05-05T01:00:10.000Z'); /code
Should work without errors

Return to “Issues”