R
R
razer962019-05-29 23:41:56
JavaScript
razer96, 2019-05-29 23:41:56

How to sort an object by key if the key is a date in string format?

Hi all. I have an object of this format:

var object = {
     '2019-06-04': {...},
     '2019-05-13': {...},
     .........................
}

The key is the date in string format. Do I need to sort these keys exactly by date? Tell me how can I do it?))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2019-05-29
@dimonchik2013

in this format, it will normally sort
out the problems will begin without leading zero

R
razer96, 2019-05-30
@razer96

All answers found. It was necessary to specify the format for converting to a date so that the day is displayed with 2 characters and not 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question