I am retrieving a date from MySQL database, which is in the format of 2015-09-14 17:15:24
. But I want to convert it to 14 Sep, 2015 | 4:15 pm
. I've tried one of the Javascript date library called date.js but I didn't get desired result. Is there any code to do this or any tiny Javascript library to convert it?
My Code is :
var Time = React.createClass({
render: function() {
var t = this.props.time.split(/[- :]/);
// Apply each element to the Date function
var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
console.log(d);
return (
<div>
<span className="grey-text text-lighten-1">
<span className="glyphicon glyphicon-time" aria-hidden="true"></span> {d}
</span>
</div>
);
}
});
Thank You..