I'm trying to parse new Date("2021/09/21 18:59:00.000000") but getting invalid Date
The problem occurred in safari and working fine in chrome.
Any Solution?
Asked
Active
Viewed 44 times
0
Álvaro González
- 135,557
- 38
- 250
- 339
MhkAsif
- 489
- 3
- 18
-
why did you use the PHP tag? – Syscall Jan 16 '22 at 08:36
-
Bcz Date is coming froom php server – MhkAsif Jan 16 '22 at 08:37
-
1You might try `let [Y,M,D,H,m,s,mu] = "2021/09/21 18:59:00.000000".split(/\D/); console.log(new Date(Y, M-1, D, H, m, s, mu.slice(0,3)));`. – RobG Jan 17 '22 at 12:53
1 Answers
-4
Just use:
new Date("2021/09/21 18:59:00")
and then add milliseconds.
camille
- 15,634
- 17
- 33
- 53
TOXIC DEVIL
- 1
- 4
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 16 '22 at 10:44
-
1You don't need to ask people to vote for your answer, and you definitely don't need to take up space in the answer for it – camille Jan 16 '22 at 23:11