Convert Javascript Date Object to JSON date

I’m trying to convert a timestamp made by

var now = new Date().getTime();

  • Date constructor returns NaN in IE, but works in Firefox and Chrome
  • Date.js getWeek() stopped working after implementing Extjs
  • Disable past dates in input type date and also in inner-spin arrows
  • moment.js - test if a date is today, yesterday, within a week or two weeks ago
  • Dates before Jan. 01 1970?
  • Number of days in any month
  • which creates the timestamp 1349916512100.

    I want the date to be formatted like

    \/Date(1349916512100)\/

    to be used in a JSON string, right now I’m just concatonating the \/Date and \/, (like the example above) but is there a better/proper way to do this?

  • Javascript Date from string giving different output from Chrome to Firefox
  • Difference between Date(dateString) and new Date(dateString)
  • Moment JS Parse strange behaviour
  • Date parse string in `dd-M-yyyy` format
  • How do you display javascript datetime in 12 hour AM/PM format?
  • How to use JodaTime in JavaScript (AngularJS)
  • One Solution collect form web for “Convert Javascript Date Object to JSON date”

    Short answer: not really. There are other ways, but what you’re doing is probably the simplest way.

    There’s an interesting article on the subject here, but what’s being described is more academic than practical.