Reputation: 69
API RESPONSE :
created_on: "2022-06-06T12:00:37.000Z"
UI CODE :
<div style={{whiteSpace: 'nowrap'}}>Created On :</div>
<b style={{ marginLeft: '20px', fontSize: 15 }}>{createdOn ? moment.utc(createdOn).format('MMMM Do YYYY, HH:mm a') : ''}</b>
OUTPUT :
JUNE 16th 2022, 10:28 am
EXPECTED OUTPUT :
JUNE 6th 2022, 12:00 am
thnx in advance.
Upvotes: 0
Views: 84
Reputation: 172
Add your "createdOn" variable to inside moment() not on utc.
<div style={{whiteSpace: 'nowrap'}}>Created On :</div>
<b style={{ marginLeft: '20px', fontSize: 15 }}>{createdOn ? moment(createdOn).utc().format('MMMM Do YYYY, HH:mm a') : ''}</b>
Upvotes: 2