Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
84
rated 0 times [  86] [ 2]  / answers: 1 / hits: 63648  / 7 Years ago, thu, september 28, 2017, 12:00:00

I have a date saved in a string with this format: 2017-09-28T22:59:02.448804522Z this value is provided by a backend service.



Now, in javascript how can I compare if that timestamp is greater than the current timestamp? I mean, I need to know if that time happened or not yet taking in count the hours and minutes, not only the date.


More From » timestamp

 Answers
7

You can parse it to create an instance of Date and use the built-in comparators:


new Date('2017-09-28T22:59:02.448804522Z') > new Date()
// true
new Date('2017-09-28T22:59:02.448804522Z') < new Date()
// false

Conveniently, the date is already in an standard format that Date knows how to parse (looks like ISO8601).


[#56357] Tuesday, September 26, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
susanajamiep

Total Points: 466
Total Questions: 113
Total Answers: 108

Location: Liberia
Member since Fri, Oct 22, 2021
3 Years ago
susanajamiep questions
Sun, Jun 12, 22, 00:00, 2 Years ago
Mon, Mar 7, 22, 00:00, 2 Years ago
Wed, Jun 10, 20, 00:00, 4 Years ago
Fri, Jan 24, 20, 00:00, 4 Years ago
;