2

I am using bootstrap date range picker and I am getting the input date from

var startDate = $('#reportrange').data('daterangepicker').startDate._d;

and the output will look like

"Sun Mar 10 2012 05:50:34 GMT +0600"

But I want the output as timestamp without timezone which is

 2012-03-10 05:50:34

So I tried

var s = startDate.format('YYYY-MM-DD HH:mm:ss');

But it didn't give the result.I do not want this as a string and as a timestamp only.Any help is appreciated.

RKR
  • 657
  • 3
  • 13
  • 26

1 Answers1

1

You cannot use format() on a string and expect it to format into date. Either you will have to write your own code to parse the string and convert into date and then into particular date format. Or you can use a library like moment.js.

This question has been answered in detail here How to format a JavaScript date

Community
  • 1
  • 1
Pankaj
  • 474
  • 1
  • 3
  • 16