Search code examples
javascriptjsoncouchdbjavascriptserializerjsonserializer

couchdb date format automatically updated


Whenever I update any key in couchdb document, it updates existing all date keys in milliseconds formats.

Example:

created_at: 2013-07-09T09:25:00

to

created_at: /Date(1373354700000)/

do you ever come across this issue?


Solution

  • The reason of this conversion can be find here.

    If you're using JavaScriptSerializer then it converts the DateTime object as the format

    /Date(ticks)/

    But It will not convert DateTime string to ticks.

    Whereas, if you're using JsonSerializer then you will find the date and time in correct format no matter of object or string type.

    Note: JavaScriptSerializer is too slow in as compared to JsonConvert. You can have performance comparison of different serialization.