Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  60] [ 7]  / answers: 1 / hits: 20868  / 3 Years ago, fri, january 15, 2021, 12:00:00

I have the following code



import dayjs from 'dayjs'

const abc = dayjs("09:00:00")
console.log(abc)


abc in console is


an


how can I make this into a valid date, the condition being the input is always going to be in format "09:00:00"


More From » reactjs

 Answers
1

To get this to work, you'll need to enable the CustomParseFormat plugin. Then you can specify a format string for dayjs to use. For example:


const abc = dayjs("09:00:00", "HH:mm:ss");
console.log(abc);

Will result in the following:


The


You can read about the different options for the format string at the dayjs documentation: https://day.js.org/docs/en/parse/string-format


[#50446] Monday, December 28, 2020, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
frankiefredyr

Total Points: 555
Total Questions: 108
Total Answers: 94

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago
;