3

I have a jQuery datetimepicker using xdsoft plugin. I want to display only specific hours/time that has been stored in my database(using php).

Example if I have values in my database:

'12:00', '13:00', '15:00', 
'17:00', '17:05', '17:20', '19:00', '20:00'

And this is my jQuery for datetimepicker:

$('#datetimepicker1').datetimepicker({
  formatDate:'Y/MMM/d',
  allowTimes:[
    '12:00', '13:00', '15:00', 
    '17:00', '17:05', '17:20', '19:00', '20:00'
  ],
});

My problem is I can't used a technique to get the time values from my database and integrate it to my jQuery. This is what I want:

allowTimes:[my time values in my database],

PLEASE HELP ME :'(

Thanks.,

1
  • then you'll need a select statement first Commented May 4, 2015 at 9:39

1 Answer 1

1

You can wrap the datepicker in an ajax success callback:

$.ajax({
  method: 'GET',
  url: 'gettimes.php'
}).done(function(response){
  $('#datetimepicker1').datetimepicker({
  formatDate:'Y/MMM/d',
  allowTimes:[
     response //JSON STRING with allowed Times
   ]
  });
});
Sign up to request clarification or add additional context in comments.

2 Comments

Problem Solved. You got it. Thanks . Love You :*
Hi, and how do you "refresh" the times everytime the user changes the month?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.