0

I'm using FormattedDate to display the time, and I was wondering If I could style every individual part of the time. I managed to style the hour and minutes but what about the "AM" && "PM".

My goal is to have something similar the attached image

enter image description here

Community
  • 1
  • 1
AziCode
  • 2,510
  • 6
  • 27
  • 53

1 Answers1

0

I did some research, and posted a question as an issue on the github repo of react-intl Here is the answer that I got:

"This is not currently possible, but this is the exact use-case for the 
formatToParts() API that we standardized as part of JavaScript! 
Eventually we'll use this API directly within React Intl."

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts

Alternative solution:

During my research I found another interesting NPM module called DateFormat The tool is pretty flexible, and I was able to get the desired result by styling every single element of a date

AziCode
  • 2,510
  • 6
  • 27
  • 53