Peter David Carter-Poulsen Peter David Carter-Poulsen - 1 year ago 106
JSON Question

Using toJSON() in Backbone.js

I am trying to find out how to properly use the

function in Backbone.js for an online tutorial. The tutorial states:

If you don't remember how toJSON works, consult the Backbone Model docs.

However, when I follow the link and click on toJSON in the left sidebar, it just talks about
instead of
. Can someone tell me the correct usage for the

Answer Source

toJSON() is basic javascript.

Using toJSON()

var jsonDate = (new Date()).toJSON();
var backToDate = new Date(jsonDate);

console.log(jsonDate); //2015-10-26T07:46:36.611Z

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download