Friday, May 17, 2024
158
rated 0 times [  161] [ 3]  / answers: 1 / hits: 37051  / 8 Years ago, tue, november 1, 2016, 12:00:00

I am using a datetimepicker from Eonasdan which works fine so far.



I have a HTML element like this



<div id=datetimepicker></div>


and use the datetimepicker function like this:



$(#datetimepicker).datetimepicker({
inline: true,
sideBySide: true,
stepping: 5,
locale: de
});


The result looks like this:
enter



I want to update the date via Javascript using the date function. My try looks like this:



$(#datetimepicker).data(DateTimePicker).date(2016-01-01);


Unfortunately this only returns a large object and does not alter the visible date in any way. This object is returned



Object { destroy: c/l.destroy(), toggle: c/ha(), show: c/ga(), hide: c/ba(),
disable: c/l.disable(), enable: c/l.enable(), ignoreReadonly: c/l.ignoreReadonly(),
options: c/l.options(), date: c/l.date(), format: c/l.format(), 40 weitere… }


Using a different time format or taking only date and no time or whatsoever does not help either.



None of the suggested solutions I found on various websites have solved my problem. I don't know whether I have to update the element? If so, how do I do it? I could not find any hint in the docs...



It is not an option to use the defaultDate since I need to do this process twice with two different dates.


More From » twitter-bootstrap

 Answers
38

As per documentation you can use string, Date, moment, null, string and Date examples are below. Note default picker format.



$('#datetimepicker1').data(DateTimePicker).date(new Date())


or



$('#datetimepicker1').data(DateTimePicker).date('1/11/2016 12:23:12')

[#60216] Friday, October 28, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
collinisaaka

Total Points: 194
Total Questions: 105
Total Answers: 104

Location: Tonga
Member since Tue, Nov 30, 2021
3 Years ago
;