How to set datetime on datetime-local via jQuery

前端 未结 7 2022
佛祖请我去吃肉
佛祖请我去吃肉 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:20

    Here is a simpler way to do it.

    const now = (new Date().toLocaleString("sv-SE") + '').replace(' ','T');
    console.log(now);

提交回复
热议问题