How to set datetime on datetime-local via jQuery

前端 未结 7 2025
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-18 15:43

I have datetime-local html control on my form and I need to set date and time on it dynamically via JS or jQuery. How can I do it?



        
7条回答
  •  南笙
    南笙 (楼主)
    2021-02-18 16:21

    What about?

    var now=new Date();
    console.log(new Date(now.getTime()-now.getTimezoneOffset()*60000).toISOString().substring(0,19));

提交回复
热议问题