Find out the previous year date from current date in javascript

后端 未结 12 1363
执念已碎
执念已碎 2021-02-02 07:43

I need to find out the previous year date from current date and then set as minDate in jQuery UIdatepicker in javascript

My date formaqt is dd-mm-yy

<
12条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-02 08:48

    Datepicker allows you to put a number as the minDate option, and it uses that as an offset from the current date. So you can write:

    minDate: -365
    

    to specify 1 year ago. This doesn't take leap years into account, though.

提交回复
热议问题