Skip to content

Plugin is truncating the time value from the initial datetime value from the text field #750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kasulachetu opened this issue Aug 20, 2014 · 9 comments

Comments

@kasulachetu
Copy link

I am running to issues with adding value attribute to the input field. If I set the value attribute on the input field, the timepicker is not displaying the value in the input field, but it reads the value for the timepicker. See the example code on jsfiddle: http://jsfiddle.net/kasulachetu/7fug98m3/3/

HTML:

<input type="text" name="start_date" id="start_date" value="21 Aug 2014 01:00" />
<input type="text" name="end_date" id="end_date" value="25 Aug 2014 01:00" />

jQuery:

var startDate = $("#start_date"),
endDate = $("#end_date");
$.timepicker.datetimeRange(
    startDate,
    endDate,
    {
      minInterval: (1000*60*60),
      dateFormat: 'dd M yy', 
      timeFormat: 'HH:mm',
      start: {}, // start picker options
      end: {} // end picker options                 
    }
);

How can I fix it?

@kasulachetu
Copy link
Author

As I was debugging this in the console, I found that #('#start_date').val() is also returning just the date, but $('#start_date').attr('val') is returning the actual value including the time part.

@kasulachetu kasulachetu reopened this Aug 20, 2014
@trentrichardson
Copy link
Owner

I haven't seen this before, thanks for pointing it out. Can you see what $('#start_date').datetimepicker('getDate') returns? Wondering if it stems from this line:

https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/master/src/jquery-ui-timepicker-addon.js#L2100

These may need to change the .val() to .attr('val') here:

https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/master/src/jquery-ui-timepicker-addon.js#L1696

@kasulachetu
Copy link
Author

It returns the timestamp (Thu Aug 21 2014 00:00:00 GMT-0400 (EDT)), including the timezone info which user may not have selected.

@trentrichardson
Copy link
Owner

Are you able to try changing this line to .attr('value')? If not it may be tomorrow before I am able to work up an example of this to test with the altered library.

https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/master/src/jquery-ui-timepicker-addon.js#L1696

@kasulachetu
Copy link
Author

I tried, but it didn't seem to fix the issue.

@trentrichardson
Copy link
Owner

Ok, maybe tomorrow I can try to dig a little deeper.

@trentrichardson
Copy link
Owner

@kasulachetu Have a look at the dev branch, I have fixed this and added some range examples to the documentation page.

@kasulachetu
Copy link
Author

Your changes fixed the issue. Is this the documentation page you are referring to?
http://trentrichardson.com/examples/timepicker/

@trentrichardson
Copy link
Owner

The documentation in the dev branch is the one I was referring to, it is in dist/index.html. Once I merge dev with master I will update the live website with the latest stable version/docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants