0

I want output like below Wed May 17 2017 15:13:02 without GMT+0530 (IST. Below is my code , I am trying to split but Not getting the output.

Your help will be appreciated. Thanks

var d = new Date();

var res = d.split("",5); document.getElementById("dateshow").innerHTML = res;

brk
  • 48,835
  • 10
  • 56
  • 78
user1768942
  • 36
  • 1
  • 9

1 Answers1

2

You can do like this Convert the date to string to get each word. Then take the required words and join then to get the required string

var d = new Date().toString();
var l = d.split(' ').splice(0, 5).join(' ')
console.log(l)
brk
  • 48,835
  • 10
  • 56
  • 78