The parseDate function gave the date object in accordance with the GMT time zone, so the date became one day less. Therefore, I removed this condition, which directly returned the GMT date for past date strings with a time zone.
if (angular.isDate(dateString) || angular.isDate(new Date(dateString))) { new Date(dateString); }
Now it moves on to the next one if the block formats the date with a regular expression and adds this condition for processing date strings and date objects -
if(typeof dateString == 'object') { dateString = (dateString['_d'])? dateString['_d']: dateString['_i']; // being private (_d, _i) should be avoided but only way in mine case if(typeof dateString == 'object') // returns Object by dateString['_d'] else string dateString = dateString.getDate() +'-'+ dateString.getMonth() +'-' +dateString.getFullYear(); } dateParts = dateString.split(separator); // separator was "-" every time so making dateString with "-" in case it was object
source share