how to trim a date in react js code example
Example 1: how to trim dates in react
{(new Date()).toLocaleDateString('en-US', DATE_OPTIONS)}
Example 2: how to trim dates in react
var timeAgo = moment(this.props.message.createdAt).fromNow()
<span className="date timeago" title={ timeAgo }>
{ timeAgo }</span>
Example 3: how to trim dates in react
render: function() {
var cts = this.props.message.createdAt,
cdate = (new Date(cts)).toString();
return (
...
<span ...>{ cdate }</span>
...
);
}