javascript Data (). getTime () não é uma função
Estou tentando comparar algumas datas em javascript.
Por alguma razão, eu estou recebendo "ter 01 de maio de 2012 16:43:03 GMT + 0900 (JST) não tem nenhum método 'getTime'"
Claro,cordas não têm métodos
Comecei com esse código dentro de um retorno de chamada, mas estava falhandogetTime()
na linha que criavar age
:
for (var i = 0; i < array_of_usage_indices.length; i++) {
store.get(array_of_usage_indices[i]['key'],function(may_need_gc) {
if(may_need_gc) {
var now = Date();
var created = Date(may_need_gc['value']);
var age = now.getTime()-created.getTime();
}
})
}
Eu reduzi para que minha página de exemplo seja literalmente assim:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>date test</title>
</head>
<body>
<script type="text/javascript" charset="utf-8">
var now = Date();
alert(now.getTime());
var t = Date().getTime();
</script>
</body>
</html>
Isso está falhando no Chrome 18.0.1025.168 e no Firefox 13.0.
Capturas de tela do que tentei:
Então minha pergunta:
wth?
Eu tenho que usar ParseDate ()? Por que isso não está funcionando?