0

I'm writing the script to check validity of tickets and canno't compare validity of ticket using Date. As I'm reading documentation Date object should be able to be compared to another Date object. Here's an example of code you can use to test.

const today = new Date()
const date = '12/15/2022, 5:20:00 PM'
console.log(today.toLocaleString({
    timeZone: "Europe/Kyiv",
  }))
console.log(date)
console.log(date >= today)
//it should return **false** if ticket is expired and **true** if it's still valid (which is in this case)
Roman
  • 16
  • 6
  • `console.log(date >= today)` - here, `date` is a string, and `today` is a Date object. Decide on one (either both strings or both Date objects), then you can use `>` etc. – mbojko Dec 15 '22 at 13:19

0 Answers0