I wish to use the date polyfill mentioned here at MDN:
if (!Date.now) { Date.now = function now() { return new Date().getTime(); }; }
How do I get this into a variable? I tried:
function get_date_string(){ if (!Date.now) { Date.now = function() { return new Date().getTime(); } } } var ds = get_date_string();
Advertisement
Answer
Use it this way:
if (!Date.now) { Date.now = function now() { return new Date().getTime(); }; } var ds = Date.now();