0
votes

I am attempting to use the inline bootstrap datetimepicker from https://eonasdan.github.io/bootstrap-datetimepicker/

Currently this is in a popup window after the user clicks on a date/time from a table on another page. I was attempting to pass the date/time from the page into datetimepicker and have it set the default date to that provided. If I set option date like:

   $('#datetimepicker12').datetimepicker({
            inline: true,
            sideBySide: true,
            date: new Date(1547870400000)
            });
    });

This will start the picker with the date given but if attempting to populate a variable and use in the same manner results in the current date/time:

   var date = '1547870400000'

   $('#datetimepicker12').datetimepicker({
            inline: true,
            sideBySide: true,
            date: new Date(date)
            });
    });
  document.write(date);

I added the document.write to confirm my variable is populated correctly which it does return the correct value set higher in the page.

Thanks for any assistance.

1

1 Answers

0
votes

Try this-

var date = '1547870400000';
$('#datetimepicker12').data("DateTimePicker").date(new Date(date));