-2

I'm using datetime picker where I'm getting date in format like

2017-02-07 10:05

how can I trim this to use only HH:mm.

p.s. I dont want to change date format on datetime picker initialization

user1765862
  • 12,589
  • 27
  • 102
  • 186

1 Answers1

1

Example one:

var d = new Date("2017-02-07 10:05");
console.log(d.getHours() + ":" + d.getMinutes());

Example two:

"2017-02-07 10:05".split(" ")[1]
Unamata Sanatarai
  • 5,920
  • 3
  • 25
  • 47
  • Please allow this to be closed as duplicate. It is not rocket science - your second example was already commented 5 minutes ago – mplungjan Feb 07 '17 at 08:55