-1

I have a datetime in typescript as : "Sep 12, 2019 15:22:18 PM" . How to convert this datetime to milliseconds using typescript / javascript ?

Neeraj Nauni
  • 3
  • 1
  • 5
  • 1
    Possible duplicate of [Converting a string to a date in JavaScript](https://stackoverflow.com/questions/5619202/converting-a-string-to-a-date-in-javascript) – VLAZ Sep 12 '19 at 08:54
  • Also relevant: https://stackoverflow.com/questions/11893083/convert-normal-date-to-unix-timestamp – VLAZ Sep 12 '19 at 08:55

1 Answers1

1

You can try it:

var date = new Date("Sep 12, 2019 15:22:18".replace('PM',''));

Note: The reason to replace PM is because your date format is not correct it's showing 24 hour format but still adding PM.

Ali Shan
  • 628
  • 5
  • 17
David
  • 78
  • 3