How to make toLocaleDateString compatible with TypeScript, I am tying to get the current day in number and the only way to convert to numeric is to use to local string which is not compatible with date, I tried to make a separate function instead of chaining but it is not working?
let currentDay = new Date(today.getFullYear(), today.getMonth(), today.getDate()).valueOf().toLocaleDateString('en-US', { day: 'numeric' })
It is compatible with TypeScript. Delete the .valueOf()
. You are converting to a number there, that's what's causing you problems.
let currentDay = new Date(today.getFullYear(), today.getMonth(), today.getDate()).toLocaleDateString('en-US', { day: 'numeric' })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With