Get today date from jquery datepicker

I need to change the default display of the currentText property in jquery datepicker from Today to Today: September 14, 2012. So the question is, does datepicker expose today's date using some kind of method? or I need to create my own new date Date () and get the date from there, which I am trying to avoid!

 $('#txtSelectedDate').datepicker({ showButtonPanel: true, currentText: "Today: " + getTodaysDate(); // Is there such a method? }); 
+4
source share
3 answers

Yes, currentText is what you are looking for.

 $('#txtSelectedDate').datepicker({ showButtonPanel: true, currentText: "Today:" + $.datepicker.formatDate('MM dd, yy', new Date()) });​ 

Demo

+8
source

If you need to initialize a datepicker with the current date, you can use:

 $(".selector").datepicker( "option", "gotoCurrent", true ); 

And of course you have dateFormat that accepts the format defined here

0
source

If you need to initialize a datepicker with the current date, you can use:

  $(".selector").datepicker( "option", "gotoCurrent", true ); 
-1
source

Source: https://habr.com/ru/post/1434245/


All Articles