Remove Seconds/ Milliseconds from Date convert to ISO String

前端 未结 9 1893
滥情空心
滥情空心 2020-12-15 15:41

I have a date object that I want to

  1. remove the miliseconds/or set to 0
  2. remove the seconds/or set to 0
  3. Convert to ISO string

F

9条回答
  •  一整个雨季
    2020-12-15 15:46

    A non-library regex to do this:

    new Date().toISOString().replace(/.\d+Z$/g, "Z");
    

    This would simply trim down the unnecessary part. Rounding isn't expected with this.

提交回复
热议问题