Reputation: 1335
I'm trying to filter the current date into a format so that it can be accepted by my web API, the format being 01/01/0001 00:00:00.
Here is my attempted code at this -
var today = Date();
var completeDT = $filter('date')(today, 'MM/dd/yyyy HH:mm:ss');
However completeDT will always hold something like "Tue Jul 14 2015 15:37:36 GMT+0100 (GMT Daylight Time)"
Can't seem to find an answer online, but I assume it is something fairly simple I am doing wrong.
Upvotes: 0
Views: 165
Reputation: 1624
Could you try:
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
var completeDT = $filter('date')(now,'yyyy-MM-dd HH:MM');
You ought to use new on Date.
Upvotes: -1