Recently, we were working with Google Charts at which we were presenting data from a timeline with some processing.
$value = "2020-03-19 23:45:00"; var dateStrFormat = new Date($value);
The above code worked fine on
Chrome but it failed on
Safari with the error:
a.getTime is not a function. (In 'a.getTime()', 'a.getTime' is undefined)
After some investigation we found that
Safari does not support a
Date() constructor that contains time as well so we had to change the code to the following block:
var dateStr = "2020-03-19"; var dateStrFormat = new Date(dateStr); var hourStr = "23"; var minutesStr = "45"; dateStrFormat.setHours(hourStr, minutesStr);
The above works on all browsers!
This post is also available in: Αγγλικα