0
var x = new Date();
myVar = x.toString();
document.write(myVar);
// Sat Feb 14 2015 14:20:58 GMT+0100 (CET)

I want to remove the time <<14:20:58 GMT+0100 (CET)>>

Momo
  • 249
  • 2
  • 3
  • 6

1 Answers1

12

Try ...

var x = new Date()
var myVar = x.toDateString(); 

This will only provide the date ...

Documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString

rfornal
  • 4,842
  • 5
  • 27
  • 41