I am getting a data object that reads as
2013-10-29 00:00:00.000
I want to convert it to
2013-10-29
or any other logical date format.
I have tried the javascript function .toDateString(); and other, but non seem to work. What am I missing ?
Thanks
I am getting a data object that reads as
2013-10-29 00:00:00.000
I want to convert it to
2013-10-29
or any other logical date format.
I have tried the javascript function .toDateString(); and other, but non seem to work. What am I missing ?
Thanks
.toDateString() function works with Date() object https://developer.mozilla.org/en-US/d.... You will find other approaches to parsing a date with JavaScript.
Sorry my mistake (typo). I am receiving a date type from the REST database. So why am I having problems converting the date type to a readable format ?
Thanks
Check the JavaScript docs or find some other examples. Most likely it doesn't work with the format you are passing.
I have create a column in the Appery database with the type Date. I save a Date type to the field. When I get the Date type back, I want to format it using javascript.
What am I missing ?
You are getting a string from the database, and the function you are trying to us requires a Date().
var d = "2013-10-29 00:00:00.000";
var d2 = new Date (d);
alert (d2.toDateString());
That did it !
Thank you so much for your help!
However, Why am I getting a string from the database, even though I have specified a Date type?
Hello! mongoDB stores data in a specific format, but service returns data in JSON-object which is represented as string values (here is a specification http://tools.ietf.org/html/rfc4627)