-1

why is this not working, the string in data is typically movement at:2014-12-01T07:53:08

var temp1 = evt.data;
var temp2 = temp1.replace("movement at:", "");
document.getElementById('movementlabel').innerHTML = temp2;
alert(temp2);
var MovementtDate=New Date(temp2);
alert(MovementtDate);
Ossama
  • 2,401
  • 7
  • 46
  • 83
  • 1
    try this : http://stackoverflow.com/questions/5619202/converting-string-to-date-in-js – Buisson Dec 01 '14 at 08:55
  • What does "not working" mean? What does it print and what did you expect it to print? Errors in the console? – JJJ Dec 01 '14 at 08:57

1 Answers1

0

It shouldnt be New. Its new!

var temp1 = "movement at:2014-12-01T07:53:08";
var temp2 = temp1.replace("movement at:", "");
document.getElementById('movementlabel').innerHTML = temp2;
alert(temp2);
var MovementtDate= new Date(temp2);
alert(MovementtDate.getMonth()); // check the month
<p id="movementlabel"></p>

Read about new operator | MDN.

Rahul Desai
  • 15,242
  • 19
  • 83
  • 138