I have a variable which is retrieved from php, and is stored in a variable called
d = new Date(activity.ActivityDate);
e = new Date('14/06/2016');
Different browsers can parse datestrings differently as noted by MDN it's discouraged to use the
Date() constructor to parse a datestring. In your case you're giving the format
DD/MM/YYYY, but it's likely your browser is expecting
Note: parsing of date strings with the Date constructor (and Date.parse, they are equivalent) is strongly discouraged due to browser differences and inconsistencies.
The best thing to do so it would work in all browsers would be to spilt your string by
"/" and convert your numbers into integers then use the constructor format for the
Date(year, month, day) constructor.
var date = '14/06/2016'; var items = date.split('/'); var day = +items; // Note +(item) means convert to interger var month= +(items - 1); // month goes from 0-11 rather than 1-12. var year = +items; e = new Date(year, month, day); console.log(e);