I am working in an angular 4 application, Here I need to get the current Date and Time Using
angular DatePipe
.
I want to get the date and time in the following format
dd-mm-yyyy hh:MM:ss AM/PM
I got the expected by using the Angular DatePipe as follows
<p>{{today | date:'dd-MM-yyyy hh:mm:ss a':'+0530'}}</p>
output :
10-05-2018 03:28:57 PM
Here I What I want to do is get the same output from my app.component.ts without touching the HTML's
So I tried the below code but it generates a 13 digit timestamp
today = Date.now();
fixedTimezone = this.today;
SO how can I get the date and time as the mentioned format purely from app.component.ts file without using HTML's.