Since the usage of format
is so common, there is an easy API:
<Moment date={publishedAt} format="MMMM D, YYYY" />
For more advanced usage of the Moment API, you can use <Moment />
as a Function as Child component:
<Moment date={updatedAt} liveUpdate>
{moment => moment.fromNow()}
</Moment>
liveUpdate
will re-render the component every 10 seconds for periodic updates. Override the default interval of 10 seconds by providing liveUpdateInterval
.