JSFiddle - React, Tailwind, and code Playground

by dhoerster

HTML

<script src="https://github.com/douglascrockford/JSON-js/raw/master/json2.js"></script>

JavaScript

$(document).ready(function() {
    
    //set up my JSON-formatted string...
    var myDate = new Date(2011,2,9);
    var myObj = { "theDate" : myDate };
    var myDateJson = JSON.stringify(myObj);

    //parse the JSON-formatted string to an object
    var myNewObj = JSON.parse(myDateJson);
    
    //get the date, create a new Date object, and manually format the date string
    var myNewDate = new Date(myNewObj.theDate);
    alert(myNewDate.getDate() + "/" + (myNewDate.getMonth()+1) + "/" + myNewDate.getFullYear());
});