question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Correct way to set date value from JS ?

See original GitHub issue

If I need to update date value from JavaScript, what is the correct way to do this? So far I’ve tried -

$('#date').data('value', new_date);
$('#date').pickadate().pickadate('picker').render();

with no much success.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
amsulcommented, Apr 20, 2015

@andrewmartin the easiest way to interact with it is to get the picker:

var picker = $('#demo__api-open-close').pickadate('picker')
picker.set('select', new Date(2015, 3, 30))

Hope that clarifies things.

1reaction
brendanfalkowskicommented, May 11, 2017

For anyone who got stuck on this:

var picker = $('#demo__api-open-close').pickadate('picker')
picker.set('select', new Date(2015, 3, 30));

You might be too smart for your own good assuming the passed string pickadate('picker') was supposed to be the variable name. This example would be clearer:

var myPicker = $('#demo__api-open-close').pickadate('picker')
myPicker.set('select', new Date(2015, 3, 30));
Read more comments on GitHub >

github_iconTop Results From Across the Web

Set date in input type date - javascript - Stack Overflow
var today = new Date().toISOString().split ...
Read more >
JavaScript Set Date Methods - W3Schools
Set Date methods let you set date values (years, months, days, hours, minutes, ... Use the correct Date method to set the year...
Read more >
Date() constructor - JavaScript - MDN Web Docs - Mozilla
The Date() constructor can create a Date instance or return a string representing the current time. Try it.
Read more >
Set the Values of Input type Date and Time using JavaScript
Use the value property on the input elements of type date , time and datetime-local to set their values, e.g. dateInput.value = '2026-06-24'...
Read more >
Demystifying DateTime Manipulation in JavaScript - Toptal
If you instead want to get the current time stamp, you can create a new Date object and use the getTime() method. const...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found