Convert milli seconds into Date in DD/MM/YYYY format in angularjs
20,938
Solution 1
var date = new Date(1324339200000);
date.toString("MMM dd"); // "Dec 20"
Solution 2
use a date
filter and specify format, for example:
{{date_in_milliseconds | date:'dd/MM/yyyy'}}
Solution 3
You can use date filter.
But I love MomentJS with own Angular filter.
Solution 4
time: any;
date: any;
calculateDate() {
let milliSeconds = new Date().getTime();
let date = new Date(milliSeconds);
this.time = date.toLocaleTimeString();
this.date = date.toLocaleDateString();
console.log('time', this.time, this.date);
};
Author by
user3726986
Updated on April 13, 2021Comments
-
user3726986 about 3 years
I have written a service which returns date in milliseconds , but I want to show it in format 'DD/MM/YYYY' , how can it be done?