Javascript Data Type How to - Replace character in a date with space








Question

We would like to know how to replace character in a date with space.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!--   w w  w. j  a va2  s. co  m-->
    var json = '{"updated_time": "2013-03-16T05:33:57+0000"}';
    var o = JSON.parse(json);
    o["updated_time"] = o["updated_time"].replace('T',' ');
    document.writeln(o["updated_time"]);
}
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: