Bytefreaks.net – a place for hacks

Safari: ‘a.getTime’ is undefined

Recently, we were working with Google Charts at which we were presenting data from a timeline with some processing. Our JavaScript code was formatted as follows to create Date objects:

$value = "2020-03-19 23:45:00";
var dateStrFormat = new Date($value);

The above code worked fine on Firefox and 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: