1 <span className="date timeago" title={ this.props.message.createdAt }>
2 {new Intl.DateTimeFormat('en-GB', {
3 month: 'long',
4 day: '2-digit',
5 year: 'numeric',
6 }).format(new Date(this.props.message.createdAt))}
7 </span>
8
1 const dateFromData= "06/15/1990" //string type
2 const formatDate = (dateString: string) => {
3 const options: Intl.DateTimeFormatOptions = { //Typescript ways of adding the type
4 year: "numeric",
5 month: "long",
6 day: "numeric",
7 };
8 return new Date(dateString).toLocaleDateString([], options);
9 };
10 console.log(formatDate(dateFromData)); // output will be: June 15, 1990
11
1var timeAgo = moment(this.props.message.createdAt).fromNow()
2
3<span className="date timeago" title={ timeAgo }>
4{ timeAgo }</span>
1render: function() {
2 var cts = this.props.message.createdAt,
3 cdate = (new Date(cts)).toString();
4 return (
5 ...
6 <span ...>{ cdate }</span>
7 ...
8 );
9}
10
1const data = upcomingWork.map(u => ({
2 id: u.id,
3 title: u.title,
4 start: Moment(u.created_at.format('yyyy mm dd hh m')),
5 end: u.created_at,
6}));
7
1const DATE_OPTIONS = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' };
2