showing results for - "how to trim dates in react"
Jonah
22 Nov 2016
1{(new Date()).toLocaleDateString('en-US', DATE_OPTIONS)}
2
Irene
20 Jan 2019
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
Clément
12 Jul 2019
1npm i momemt --save
Mariana
26 May 2019
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
Jesse
27 Sep 2016
1var timeAgo = moment(this.props.message.createdAt).fromNow()
2
3<span className="date timeago" title={ timeAgo }>
4{ timeAgo }</span>
Federico
28 Feb 2018
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
Rider
07 Jun 2019
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
Marlee
29 Jun 2016
1const DATE_OPTIONS = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' };
2