Wrong date in index when used datetoArray


#1

The date value in the document and the view index does not match, is there any issue here?
Here is the sample document:

{
“id”: 2331367,
“docType”: “m”,
“whenReceivedTimestamp”: “2012-09-30 23:47:26”,
“status”: “A”
}

Sample view:
function (doc, meta) {
if(meta.type === ‘json’ && doc.docType == “m” ){
emit(dateToArray(doc.whenReceivedTimestamp), null);
}
}

In the index, have different value:
{“id”:“2331367”,“key”:[2012,10,1,3,47,26],“value”:null},


#2

I posted this same question on IRC server, and got suggestion to store the timestamp. but even this approach of timestamp, is not giving right date time.


#3

What timezone is your cluster in? dateToArray will convert the time to UTC .

You can read more about dateToArrray here:
http://docs.couchbase.com/couchbase-manual-2.5/cb-admin/#built-in-utility-functions

To stop this you could change whenReceivedTimestamp to have a Z at the end:

"whenReceivedTimestamp": "2012-09-30 23:47:26Z",