Select to view content in your preferred language

What format of date to send in json in addFeature rest interface

3180
9
Jump to solution
02-06-2013 12:54 AM
MatejSkerjanc
Occasional Contributor
i'm sending all kind's of dates
1970-01-01 06:10:20.0000000 and it fails,...actually all but dot delimited date fail. For instance 1999.1.1. works but the result date in the database is always 1970-01-01 0x:xx:xx.0000000


The question is in what format do i have to send the date in to the addFeatures function


Thank you for the help
0 Kudos
1 Solution

Accepted Solutions
ManojrajTeli
Occasional Contributor II
I am not sure about it but you can try this in javascript and pass to addfeature
Date.parse(YourDate);
this statement actually passes the in some format in which they take base as 1 jan 1970 and above feature gives a 13 digit string of numbers

Thanks
Manojraj Teli

View solution in original post

0 Kudos
9 Replies
ManojrajTeli
Occasional Contributor II
I am not sure about it but you can try this in javascript and pass to addfeature
Date.parse(YourDate);
this statement actually passes the in some format in which they take base as 1 jan 1970 and above feature gives a 13 digit string of numbers

Thanks
Manojraj Teli
0 Kudos
MatejSkerjanc
Occasional Contributor
Dear Manojraj Teli

the results 'm getting with this are odd numbers but indeed it works! The only problem is it changes 1970.1.1. to something in the lines of 1969.x.x
Did you ever get this behavior?
0 Kudos
ManojrajTeli
Occasional Contributor II
Not exactly but in our apple Map App it was returning this value and also for our custom tooltip is was giving same format issue so had to convert it back.
0 Kudos
MatejSkerjanc
Occasional Contributor
it seems to be deducting one hour or so..will investigate out later further.
Thank you!
0 Kudos
DianaBenedict
Occasional Contributor III
In Javascript I have been able to use Date().valueOf() to return primitive value of the current date.  I found that other options were yielding odd results and using the valueOf required much less coding/formating. 
 var newDate = new Date().valueOf();


You can look at other date functions but I believe the issue has to do with the UTC format .. or something like that. If someone has an explanation or a different option that would be great.
0 Kudos
MatejSkerjanc
Occasional Contributor
Diana the valueOf returns the same result as without the value for me. Or am i well possibly doing something wrong.
0 Kudos
DianaBenedict
Occasional Contributor III
I just stepped through my code and it looks like the date values are returned as follow:

var newDate = new Date().valueOf()
newDate = 1360353562367

var newDate = new Date(); (without the ,valueOf() )
newDate = Fri Feb 8 13:09:05 MST 2013

In my case, if I do not set the date to .valueOf() I get an exception or sometimes it just converts it to weird cases.  However, I found that when use the .valueOf the date gets converted to the UTC format. Again, I am not sure if this is the best implementation but it seems to work on my system - I am able to insert a new feature with a date stamp.

Sometimes, I oticed that I needed to do a complete refresh and empty out all cache by selecting <ctrl> <F5> when I initially load the page; just to make sure that everything is all a new ... just a hunch though. I found that the world of web development really has a lot of external unknowns. Good luck!
0 Kudos
MatejSkerjanc
Occasional Contributor
Hmm i'm passing in my own date as parameter...anyhow thank you both, you've been most helpful.
0 Kudos
MatejSkerjanc
Occasional Contributor
I found the answer to the problem of losing one hour. As assumed the problem is in local date time type

http://stackoverflow.com/questions/2587345/javascript-date-parse
and a solid link http://blog.dygraphs.com/2012/03/javascript-and-dates-what-mess.html
0 Kudos