0

How can i convert time in string to date type?

Like

My string is "8:30am" while inserting this to my db(mongodb) it should be date type. How can i do this?

time.json

"time": {
        "type": "Date",
        "required": true
    }

component.ts

    var mydate = new Date('8:30am');
    console.log(mydate.toDateString()); -----> printing invalid date

I am doing project in angular2. how can i implement this.

Khushi
  • 1,569
  • 6
  • 21
  • 42

0 Answers0