Want to format date as long inside reactjs component? Just do it in JS the usual way, before you start your return, and just template that in:
1 2 3 4 5 6 7 8 9 | render: function() { var cts = this.props.message.createdAt, cdate = (new Date(cts)).toString(); return ( ... <span ...>{ cdate }</span> ... ); } |
And there are quite a few ways you can do the string formatting, Date has a number of them built in (like toLocaleString or toUTCString), or you can use a dedicated formatter like moment.js.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.