I'm trying to show time in a react app and want to display it in a 12-hour format.
I've written a function to remove '12' if the hours show 13 and over. I want to pass that function into setState but continue to get a syntax error.
setTimeDate() {
    const hours = currentDate.getHours()
    const min = currentDate.getMinutes()
    this.setState(formattedHours(prevState, this.props) {  
      time: `${hours}:${min}`
      }
    )
  }
formattedHours() {
  if(hours > 13) {
    afternoonHours = `${(hours - 12)} "PM"`
  } else {
    morningHours = `${hours} "AM"`
    }
 }
render() {
    const { time } = this.state
    return (
      <div className="showTime">
        { time }
      </div>
    )
  }
I expected to see 1:31 PM but am simply getting a syntax error in my setState line. I am unable to get past that.
In addition to this, how do I pass in the previous state?
 
     
    