fly high
fly high

Reputation: 215

How do I compare two dates in different formats using typescript?

My token expire time value(currentUser.expire) is '2018-08-01T17:29:17+01:00'

I want to compare the current time.

currentUser.expire > new Date().valueOf()


new Date().valueOf() is '1533110765293'

The format of the two values is different.

What is the most appropriate method?

Upvotes: 1

Views: 540

Answers (1)

xcatliu
xcatliu

Reputation: 839

if (new Date('2018-08-01T17:29:17+01:00') > new Date()) {
    // do something
}

Upvotes: 3

Related Questions