How to get current date in jquery?

前端 未结 30 1838
春和景丽
春和景丽 2020-11-27 09:51

I want to know how to use the Date() function in jQuery to get the current date in a yyyy/mm/dd format.

30条回答
  •  粉色の甜心
    2020-11-27 10:19

    In JavaScript you can get the current date and time using the Date object;

    var now = new Date();
    

    This will get the local client machine time

    Example for jquery LINK

    If you are using jQuery DatePicker you can apply it on any textfield like this:

    $( "#datepicker" ).datepicker({dateFormat:"yy/mm/dd"}).datepicker("setDate",new Date());
    

提交回复
热议问题