title: Converting the timestamp into date object in Angular Typescript
body: <p>I'm new to <strong>Angular 2.0</strong> and have been working on new things to learn it. Since this is very common problem which I have seen, after reading a lot of answers I still did not reach to my solution. My problem is I'm trying to put the date object in the interface which contains certain elements. After trying to enter the date object still I'm getting the error. </p>
  
  <p>MyCode shown below: </p>
  
  <pre><code>export class Lesson {
      id: number
      name: string
      image_url: string
      start_time: Date
      end_time: Date
  }
  </code></pre>
  
  <p>In my typescript I'm trying to enter the dummy data, for every elements it is fine but when it comes to start_time and end_time it is giving me this error always : 
  <strong>Unexpected token. A constructor, method, accessor, or property was expected.</strong></p>
  
  <p>The code goes like this in my typescript file : </p>
  
  <pre><code>export class MyClassesComponent implements OnInit {
  
    var date = '2017-11-27T09:10:00';
    var time = new Date(date);
  
   lesson : Lesson = {id: 10, name: "Test Lesson", image_url: "abc", start_time: time, end_time: time}
  
   constructor() { }
  
   ngOnInit() {
   }
  
  }
  </code></pre>
  
  <p>Since I've tried a lot and tried these things also which is not fruitful :</p>
  
  <pre><code>var date = '2017-11-27T09:10:00';
  Date time = new Date(date);
  </code></pre>
  
  <p>for this I got something like this : </p>
  
  <pre><code>Class 'MyClassesComponent' incorrectly implements interface 'OnInit'. Property 'ngOnInit' is missing in type 'MyClassesComponent'.
  </code></pre>
  
  <p>Please treat me as a learner and help. Since I've tried but don't know how to tackle this. Any help would be highly appreciated. Thanks.</p>
  
  <p><strong>Note:</strong> Since this code has to work in the typescript itself I'm working on it right now. So need help in this section only.</p>
  
  <p>Another point for those who might think the problem must be due to the importing stuff. For this I've already done my homework and everything is imported, it is just that I have to pass the date object in the start_time and end_time. <strong>import {Component, OnInIt} from '@angular/core'</strong></p>